Page 1 of 1

b1142.2 obeyEMCOM property

Posted: Sat Apr 18, 2020 7:47 pm
by KnightHawk75
Anyone figured out how to access this Boolean property correctly yet?

Code: Select all

 local u = ScenEdit_GetUnit(guid='blalba');
 u.obeyEMCOM = false; -- throws casting exception
 print(tostring(u.obeyEMCOM)); -- throws casting exception.
 print(u.obeyEMCOM); -- returns 'keralua.luafunction'
 u.obeyEMCOM(false); -- invoke invalid method as expected.
 
 casting exception:
 System.InvalidCastException: Unable to cast object of type
  'KeraLua.LuaFunction' to type 'System.Reflection.MemberInfo'.
   at NLua.MetaFunctions.TrySetMember(Lua luaState,
  ProxyType targetType, Object target, BindingFlags bindingType,
  String& detailMessage)
 at NLua.MetaFunctions.SetFieldOrPropertyInternal(Lua luaState)
 at NLua.MetaFunctions.SetFieldOrProperty(IntPtr state)
 at KeraLua.NativeMethods.lua_pcallk(IntPtr luaState, Int32 nargs,
 Int32 nresults, Int32 errorfunc, IntPtr ctx, IntPtr k)
 at NLua.Lua.DoString(String chunk, String chunkName)
 at Command_Core.Lua.LuaSandBox.RunScript(String str, 
 Boolean RunInteractively, String script),nil
 

RE: b1142.2 obeyEMCOM property

Posted: Sat Apr 18, 2020 10:15 pm
by michaelm75au
It is working for me.
I ran this on the Mines Tutorial using 1142.2 over my Steam copy.
>> local u = ScenEdit_GetUnit({name='Fleet Class CUSV [MCM Mission Module]', guid='0c95b41f-6ede-4c3f-9167-2a1900c04a6a'})
print(u.obeyEMCON)
u.obeyEMCON = false
print(u.obeyEMCON)

'Yes'
'No'

RE: b1142.2 obeyEMCOM property

Posted: Sat Apr 18, 2020 10:19 pm
by michaelm75au

Code: Select all

u.obeyEMCO[b]M[/b] = false; -- throws casting exception

Incorrect name I just noticed - > obeyEMCON

RE: b1142.2 obeyEMCOM property

Posted: Sun Apr 19, 2020 12:32 am
by KnightHawk75
ORIGINAL: michaelm75au

Code: Select all

u.obeyEMCO[b]M[/b] = false; -- throws casting exception

Incorrect name I just noticed - > obeyEMCON


OMG am I an idiot or what! I knew I had to be doing something wrong. doh.
Thanks, sorry for wasting your time.