Fandom

Glest

Lua/Commands

< Lua

275pages on
this wiki
Add New Page
Talk0 Share

Lua is the scripting language for Glest, and is used to create scenarios. This page does not explain how to create such scenarios or how to use Lua, but is a collection of the Lua commands available for Glest. For an explanation of how to use Lua in Glest, please see the Lua page.

This page is just for the shared commands between all three engines, regular Glest, GAE, and MegaGlest. For a full list of Lua functions only available in GAE, see GAE/Lua. For a full list of Lua functions only available in MegaGlest, see MG/Lua.

Game Control Edit

disableAi(factionIndex) Edit

Disables AI control of a faction.

Parameters:

  • factionIndex: the index of the faction to disable the AI on.

setPlayerAsWinner(factionIndex) Edit

Sets a faction as having won the game.

Parameters:

  • factionIndex: the index of the faction to set as a winner.

endGame() Edit

Finishes the game.

Gui Control Edit

setCameraPosition(pos) Edit

Move the camera so that the cell at pos is in the centre of the view.

Parameters:

  • pos: a position to move the camera to, a tables with two values { x, y }

User Feedback Edit

showMessage(text, header) Edit

Displays a message to the user in a messagebox that must be dismissed, the game is paused when the message is shown.

Parameters:

  • text: A string identifying the text to look up in the lang file, this is the 'body' of the message.
  • header: A string, looked up in the lang file, for the message box 'title-bar'

setDisplayText(text) Edit

Displays a message to the user at the top of the screen, remains until setDisplayText() is called again, or clearDisplayText() is called.

Parameters:

  • text: A string identifying the text to look up in the lang file, the text for to display

clearDisplayText() Edit

Clears the display message from the top of the screen.

Unit creation and Resource/Upgrade hand-outs Edit

createUnit(type, factionIndex, pos) Edit

Create a unit a unit for a faction at (or near) pos.

Parameters:

  • type: The unit type to create
  • factionIndex: The index of the faction to create the unit for
  • pos: a position to create the unit at (or near), array of two elements { x, y }

giveResource(type, factionIndex, amount) Edit

Gifts some resources to a faction (don't forget to make sure they can store them!)

Parameters:

  • type: The resource type
  • factionIndex: The index of the faction to give resources to
  • amount: the amount of the resource to give

Unit commands Edit

givePositionCommand(unitId, command, pos) Edit

Give a position based command to a unit

Parameters:

  • unitId: The ID of the unit to give the command to
  • command: the name of the command to give, one of 'move', or 'attack'
  • pos: the command's target position { x, y }

giveProductionCommand(unitId, unitType) Edit

Give a poduce or morph command to a unit

Parameters:

  • unitId: The ID of the unit to give the command to
  • unitType: the type of unit to produce

giveUpgradeCommand(unitId, upgrade) Edit

Give an upgrade command to a unit.

Parameters:

  • unitId: The ID of the unit to give the command to
  • upgrade: the Upgrade to produce

Queries Edit

startLocation(factionIndex) Edit

Returns a start location, as an array of two elements.

Parameters:

  • factionIndex: The index of the faction

unitPosition(unitId) Edit

Returns the location of a unit, as an array of two elements.

Parameters:

  • unitId: The ID of the unit.

unitFaction(unitId) Edit

Returns the faction index of a unit.

Parameters:

  • unitId: The ID of the unit.

resourceAmount(resource, factionIndex) Edit

Returns the amount of a resource a player has.

Parameters:

  • resource: A string identifying the resource of interest
  • factionIndex: The index of the factiont.

lastCreatedUnit() Edit

Returns the ID of the last created unit.

lastDeadUnit() Edit

Returns the ID of the last unit to die.

unitCount(factionIndex) Edit

Returns the number of units a player has.

Parameters:

  • factionIndex: The index of the faction

unitCountOfType(factionIndex, type) Edit

Returns the number of units of a specific type a player has.

Parameters:

  • factionIndex: The index of the faction
  • type: String identifying the unit type of interest

See AlsoEdit

External LinksEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.