how to correctly invoke methods of a wrapper?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
DracheTek
Posts: 46
Joined: Sun Jul 05, 2020 11:55 am

how to correctly invoke methods of a wrapper?

Post by DracheTek »

for example:

Code: Select all

>> target = ScenEdit_GetUnit({name='Taichung A/C Revetment (1x Large Aircraft)', guid='*SOME GUID THAT LOOKED LIKE PHONE NUMBER TO THE FORUM SYSTEM'})
 target.delete()
 ERROR: [string "Console"]:2:  instance method 'delete' requires a non null target object


so how to correctly invoke methods of a wrapper?
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: how to correctly invoke methods of a wrapper?

Post by michaelm75au »

Taking the unit wrapper as example:
If you look up Command page http://commandlua.github.io/index.html#wrapper_Unit
it will show you the various properties of that wrapper.

There are also some examples of how they are accessed on the page.
Michael
DracheTek
Posts: 46
Joined: Sun Jul 05, 2020 11:55 am

RE: how to correctly invoke methods of a wrapper?

Post by DracheTek »

OK. 'Delete' is an "instance method", which needs a "self" parameter. using target:delete() will correctly invoke it.
Post Reply

Return to “Lua Legion”