LuaLibraries.wiki
changeset 526 f910cf3241fc
parent 525 b051cfd45c23
child 527 908428bf4a03
--- a/LuaLibraries.wiki	Sat Dec 20 19:36:54 2014 +0000
+++ b/LuaLibraries.wiki	Sun Dec 21 01:04:48 2014 +0000
@@ -308,4 +308,38 @@
 RemoveEventFunc(condFunc2, condArgs1) --Removes a single event</code>
 
 === !CheckEvents ===
-<blockquote> Verifies all the condition functions in the events list and calls the respective 'action' functions if the conditions are met. If the evType of a completed event is 0 then it is removed from the list. This function is best placed in onGameTick.</blockquote>
\ No newline at end of file
+<blockquote> Verifies all the condition functions in the events list and calls the respective 'action' functions if the conditions are met. If the evType of a completed event is 0 then it is removed from the list. This function is best placed in onGameTick.</blockquote>
+
+
+= Params =
+The Params library is a small library introduced in 0.9.21. It provides a function to parse the parameter string `ScriptParam` and it is intended to simplify using this string.
+
+This library requires the parameter string to be in a certain format. It must be a comma-seperated list of kev-value pairs in the `key=value` format. Examples:
+{{{
+speed=1
+health=100, ammo=5
+param1=hello, param2=whatever, param3=5325.4
+}}}
+
+Using this library is by no means neccessary.
+
+== `parseParams()` ==
+Parses `ScriptParam` and writes the result into the global table `params`. The table will follow the `key=value` pattern. Both keys and pairs are stored as string.
+
+=== Example  ===
+<code language="lua">
+function onParameters()
+    parseParams()
+    if params["myparam1"] == "hello" then
+        WriteLnToConsole("Hello World!")
+    end
+end
+</code>
+
+If the key-value pair `myparam1=hello` is present, this script writes “Hello World!” in the console. All these inputs would trigger the event:
+
+{{{
+myparam1=hello
+myparam2=whatever, myparam1=hello
+g=4, f=56, m=56, myparam1=hello
+}}}
\ No newline at end of file