# HG changeset patch # User almikes@aol.com # Date 1418687497 0 # Node ID a79631e03c84aa4284021dec6e57d060b7f528a6 # Parent fbc43fa808ff0175a6bba6ff74e45417dcaecc22 Add onParameters and ScriptParam diff -r fbc43fa808ff -r a79631e03c84 LuaAPI.wiki --- a/LuaAPI.wiki Mon Dec 15 23:00:55 2014 +0000 +++ b/LuaAPI.wiki Mon Dec 15 23:51:37 2014 +0000 @@ -150,11 +150,20 @@ Can be used to show the mission and for more setup, for example initial target spawning. -=== onPreviewInit() === +=== onPreviewInit() (0.9.21) === This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter. It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend. +=== onParameters() (0.9.21) === +This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`. + +Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that. + +*Tip*: If you use the Params library (`/Scripts/Params.lua`), you can make the task of dissecting the string into useful values a bit easier, but it’s not required. (The Params library is not documented yet, however). + +*Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly. + === onGameTick() ===
This function is called on every game tick, i.e. 1000 times a second. If you just need to check on something periodically, consider...