From 8e4765ca46e14db2baf4300b03dd5d1db476afd4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 25 Oct 2014 16:47:38 +1300 Subject: [PATCH] Allow integers to bridge to enums. --- OpenRA.Mods.RA/Scripting/Global/ActorGlobal.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Scripting/Global/ActorGlobal.cs b/OpenRA.Mods.RA/Scripting/Global/ActorGlobal.cs index c7c3ba6554..178d07a2ef 100644 --- a/OpenRA.Mods.RA/Scripting/Global/ActorGlobal.cs +++ b/OpenRA.Mods.RA/Scripting/Global/ActorGlobal.cs @@ -39,11 +39,12 @@ namespace OpenRA.Scripting var genericType = initType.GetInterfaces() .First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IActorInit<>)); var innerType = genericType.GetGenericArguments().First(); + var valueType = innerType.IsEnum ? typeof(int) : innerType; // Try and coerce the table value to the required type object value; - if (!kv.Value.TryGetClrValue(innerType, out value)) - throw new LuaException("Invalid data type for '{0}' (expected '{1}')".F(typeName, innerType.Name)); + if (!kv.Value.TryGetClrValue(valueType, out value)) + throw new LuaException("Invalid data type for '{0}' (expected '{1}')".F(typeName, valueType.Name)); // Construct the ActorInit. Phew! var test = initType.GetConstructor(new[] { innerType }).Invoke(new[] { value });