Editing MG/Lua
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
[[Lua]] is the scripting language used in [[MegaGlest]]'s [[scenarios]]. It allows scenarios to expand and do things not normally possible in regular games of Glest. This page lists all the Lua commands available in MegaGlest. For information on how to create scenarios and working with Lua in general, see [[Lua]]. | [[Lua]] is the scripting language used in [[MegaGlest]]'s [[scenarios]]. It allows scenarios to expand and do things not normally possible in regular games of Glest. This page lists all the Lua commands available in MegaGlest. For information on how to create scenarios and working with Lua in general, see [[Lua]]. | ||
− | |||
− | |||
==Text== | ==Text== | ||
Line 140: | Line 138: | ||
'''unitID''' - The ID of the unit to give the kills to.<br /> | '''unitID''' - The ID of the unit to give the kills to.<br /> | ||
'''amount''' - The number of kills given. | '''amount''' - The number of kills given. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===selectUnit(unitID)=== | ===selectUnit(unitID)=== | ||
Line 216: | Line 192: | ||
Parameters:<br /> | Parameters:<br /> | ||
'''pos''' - an array of two elements, specifying the co-ordinates {x,y}. | '''pos''' - an array of two elements, specifying the co-ordinates {x,y}. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===togglePauseGame(pauseStatus)=== | ===togglePauseGame(pauseStatus)=== | ||
Line 249: | Line 209: | ||
=== loadScenario(scenario, keepFactions) === | === loadScenario(scenario, keepFactions) === | ||
− | Loads another scenario from inside an existing scenario. The new scenario must have the same techtree and factions, but map, tileset can change. | + | Loads another scenario from inside an existing scenario. The new scenario must have the same techtree and factions, but map, tileset can change. |
Parameters:<br /> | Parameters:<br /> | ||
Line 263: | Line 223: | ||
===getAttackWarningsEnabled()=== | ===getAttackWarningsEnabled()=== | ||
Returns the current status of the attack warnings system (true if enabled, false if disabled). | Returns the current status of the attack warnings system (true if enabled, false if disabled). | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==AI== | ==AI== | ||
Line 406: | Line 339: | ||
Parameters:<br /> | Parameters:<br /> | ||
'''pos''' - the x and y coordinate of the top left point then the bottom right point (eg, {10,10,5,5} would create a box from points (10,10) to (5,5)). | '''pos''' - the x and y coordinate of the top left point then the bottom right point (eg, {10,10,5,5} would create a box from points (10,10) to (5,5)). | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===triggeredEventAreaEntryUnitId()=== | ===triggeredEventAreaEntryUnitId()=== | ||
Line 433: | Line 345: | ||
===triggeredEventAreaExitUnitId()=== | ===triggeredEventAreaExitUnitId()=== | ||
Returns the unit ID of the unit who exited a registered cell area trigger event. | Returns the unit ID of the unit who exited a registered cell area trigger event. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===getCellTriggerEventCount(eventID)=== | ===getCellTriggerEventCount(eventID)=== | ||
Line 459: | Line 360: | ||
Parameters:<br /> | Parameters:<br /> | ||
'''eventID''' - the ID of a previously registered event. | '''eventID''' - the ID of a previously registered event. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===startTimerEvent()=== | ===startTimerEvent()=== | ||
Line 672: | Line 541: | ||
===getUnitsForFaction(factionIndex, commandTypeName, field)=== | ===getUnitsForFaction(factionIndex, commandTypeName, field)=== | ||
− | Returns an array (table) of units in the specified faction which | + | Returns an array (table) of units in the specified faction which: |
− | <tt>0</tt> | + | *If only the commandTypeName is specified, the table will be a list of all units which have that command (such as <tt>attack</tt>). |
− | + | *If the commandTypeName is empty and only the field is specified (<tt>0</tt> = land, <tt>1</tt> = air), the table will list all units which are in that specific field. | |
− | + | *If both commandTypeName and the field are specified, the table will list all units which have the specified command can can use it on the specified field (such as being able to attack air units). | |
− | |||
===getUnitCurrentField(unitId)=== | ===getUnitCurrentField(unitId)=== | ||
Line 692: | Line 560: | ||
Parameters:<br /> | Parameters:<br /> | ||
− | '''flashCount''' -<br /> | + | '''flashCount''' - <br /> |
'''factionIndex''' - index of the faction who "placed" the marker.<br /> | '''factionIndex''' - index of the faction who "placed" the marker.<br /> | ||
'''note''' - note on the marker.<br /> | '''note''' - note on the marker.<br /> | ||
Line 702: | Line 570: | ||
Parameters:<br /> | Parameters:<br /> | ||
− | '''factionIndex''' - index of the faction whose camera you wish to move.<br /> | + | '''factionIndex''' - index of the faction whose camera you wish to move.<br /> |
'''pos''' - x and y coordinates for the camera's position. | '''pos''' - x and y coordinates for the camera's position. | ||
Line 709: | Line 577: | ||
Parameters:<br /> | Parameters:<br /> | ||
− | '''teamNumber''' - team number whose camera you wish to move.<br /> | + | '''teamNumber''' - team number whose camera you wish to move.<br /> |
'''pos''' - x and y coordinates for the camera's position. | '''pos''' - x and y coordinates for the camera's position. | ||
Line 715: | Line 583: | ||
These are XML tags used to execute Lua code on its specified event. Variables can be used across different events. | These are XML tags used to execute Lua code on its specified event. Variables can be used across different events. | ||
− | <syntaxhighlight lang="xml">< | + | <syntaxhighlight lang="xml"><startup> |
<!-- | <!-- | ||
− | Code here will be executed | + | Code here will be executed once on startup. |
--> | --> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<startup> | <startup> | ||
− | |||
− | |||
− | |||
− | |||
<unitCreatedOfType type="unitname"> | <unitCreatedOfType type="unitname"> | ||
<!-- | <!-- | ||
Line 790: | Line 643: | ||
[[Category:Scenarios]] | [[Category:Scenarios]] | ||
[[Category:Lua]] | [[Category:Lua]] | ||
− |