Add onParameters and ScriptParam
authoralmikes@aol.com
Mon, 15 Dec 2014 23:51:37 +0000
changeset 505 a79631e03c84
parent 504 fbc43fa808ff
child 506 c619a5931ee5
Add onParameters and ScriptParam
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 @@
 </blockquote>
 Can be used to show the mission and for more setup, for example initial target spawning.
 
-=== <tt>onPreviewInit()</tt> ===
+=== <tt>onPreviewInit()</tt> (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.
 
+=== <tt>onParameters()</tt> (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.
+
 === <tt>onGameTick()</tt> ===
 
 <blockquote>This function is called on every game tick, i.e. 1000 times a second.  If you just need to check on something periodically, consider...