b1142.2 obeyEMCOM property

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

b1142.2 obeyEMCOM property

Post 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
 
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: b1142.2 obeyEMCOM property

Post 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'
Michael
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: b1142.2 obeyEMCOM property

Post by michaelm75au »

Code: Select all

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

Incorrect name I just noticed - > obeyEMCON
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: b1142.2 obeyEMCOM property

Post 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.
Post Reply

Return to “Lua Legion”