LUA script console - hint (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


michaelm75au -> LUA script console - hint (5/22/2016 7:04:45 AM)

As well as using this to test your script snippets, leaving this open while testing events with LUA scripting is also useful.
Any print(..) statements you may have in the LAU action/trigger scripts should also print out in this window. This is very helpful when trying to debug why an event's script is not working - print out the variables, unit tables, etc.
However it is also a good idea to try to make the prints a bit verbose; a number on the screen does not say much.
eg: embedding this is in the event - print('MyEvent: random number = ' .. a) - would print out the value of 'a' during the 'MyEvent'.

I would also suggest commenting these lines out [add 2 dashes in front of it --print('MyEvent: random number = ' .. a)] before publishing to stop them from polluting the Console in case the player is also doing some in it.
I find commenting them out rather than deleting them, is more useful, as at some point you may need to go back to the script for some issue.[:D]




mikmykWS -> RE: LUA script console - hint (5/24/2016 3:44:32 PM)

Pinned and FAQ'd.




michaelm75au -> RE: LUA script console - hint (2/11/2017 11:55:18 PM)

In SR7, some new tools have been added to help with Events.
1. Tool_DumpEvents(): This will dump out the event/trigger/condition/action to a file so they can be visually checked.
2. The Lua script in the Event can be recorded in the Lua history log. This is useful during testing but could be detrimental if it keeps firing during a game. To turn on this logging, run the line '_lua_event=true' in the Script Console and leave the console open. To run off, just run '_lua_event=false'.




michaelm75au -> RE: LUA list of wrapper fields - hint (3/24/2018 4:20:36 PM)

To get a list of fields in a Command Lua wrapper
1. Get an object wrapper (eg unit = ScenEdit_GetUnit())
2. List the properties ( eg print(unit.fields) )
3. Properties consists of (a) name, (b) type of property, and (c) if you set a value for it (eg unit fields = { property_29 = '.damage , LuaTable , False', property_19 = '.dbid , Int32 , False', method_1 = ':delete , System.Void', property_28 = '.loadoutdbid , Object , False', method_2 = ':inArea , System.Boolean, property_9 = '.course , LuaTable , True' ...
-> property_29 : unit.damage is a Lua table and you can't set a value as in unit.damage = {}
-> property_19 : unit.dbid is a number and you can't set a value as in unit.dbid = 12
-> property_28 : unit.loadoutdbid is a generic object and you can't set a value as in unit.loadoutdbid = 1234
-> property_9 : unit.course is a Lua table and you can set a value as in unit.course = {...}
-> method_1 : unit:delete is a Lua method/function and returns nothing
-> method_2 : unit:inArea is a Lua method/function and returns true/false




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.859375