Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA script console - hint

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA script console - hint Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA script console - hint - 5/22/2016 7:04:45 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
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.

< Message edited by mikmyk -- 5/24/2016 3:45:42 PM >


_____________________________

Michael
Post #: 1
RE: LUA script console - hint - 5/24/2016 3:44:32 PM   
mikmykWS

 

Posts: 11524
Joined: 3/22/2005
Status: offline
Pinned and FAQ'd.

_____________________________


(in reply to michaelm75au)
Post #: 2
RE: LUA script console - hint - 2/11/2017 11:55:18 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
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'.

_____________________________

Michael

(in reply to mikmykWS)
Post #: 3
RE: LUA list of wrapper fields - hint - 3/24/2018 4:20:36 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
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

_____________________________

Michael

(in reply to michaelm75au)
Post #: 4
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA script console - hint Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.953