Topic: How to use the the game script shell

Lastmerlin on June 10, 2010, 03:44:19 PM


  • Administrator
  • Sr. Member
  • *****
  • Posts: 463
  • Karma: +5/-0
    • View Profile
For testing purpose, executing arbitrary script commands at runtime is very useful.
This is done by using the ingame chat line. Each line that starts with a dollar sign ($) is considered as a command. All valid lua commands are allowed.

Moreover, gamespecific functions are defined. See the Script documention for a reference of all implemented functions (look into the files section). The functions are documented as if they were c functions but of course they are lua functions ingame. The C API style is just used to display the expected type of arguments. Be aware that there is no automatic typechecking in lua.

Additional function can be created in .lua files, that are placed in the data/lua folder. All functions defined there will be available in game. Do not modify the the files that are under version control, create new ones instead. A very popular function for debugging is for instance:
Code: [Select]

function plpos()
        pl = getPlayers()[1];
        pos = get(pl,"position");

This function stores the ID of the player into the global variable pl and its current position into a table {x,y} named pos.

After that, player variables can be easily changed, for instance
Code: [Select]
... improves your financial situation considerably.

Be aware that cheating may spoil game fun very fast.
  • Read 6064 times
  • Category Scripting
Comments: 2

fusion44 on June 13, 2010, 12:39:00 PM
Reply #1


  • Administrator
  • Sr. Member
  • *****
  • Posts: 459
  • Karma: +10/-0
    • View Profile
I've started implementing a Lua editor, but its rather unintuitive at the moment. Its not meant to be a full featured Lua editor by any means but for a quick bug fix this should be more than fine. The UI is rather unintuitive beacause CEGUI doesn't provide a ready to use file browser so everything is done through the edit box besides the execute button (which isn't used atm).

If we can retrieve the line and the filename where an error occurred we can jump to the specific line in the code and fix it. If we can tell Lua to re-parse the file we can even try again without reloading the whole game.

Spekkie on May 16, 2013, 03:38:59 PM
Reply #2


  • Newbie
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Since I can't seem to find the scripting documentation anymore, I'lll just ask it.
As far as I know, the entire campaign is based on scripting (which region to load, how it looks like and so on)
But for testing purposes, how can I use one of the testmaps?