changeset 1329 bd781e19a52d
child 1339 0b7f8de0843c
equal deleted inserted replaced
1328:7c0b4029caa1 1329:bd781e19a52d
     1 #summary Lua library documentation: Params
     2 #labels LuaLibrary
     4 = Lua library: `Params` =
     5 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.
     7 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:
     9 <code>speed=1</code>
    10 <code>health=100, ammo=5</code>
    11 <code>param1=hello, param2=whatever, param3=5325.4</code>
    13 Using this library is by no means neccessary, you could use practically whatever syntax you wish if you write your own code for parsing.
    15 == `parseParams()` ==
    16 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.
    18 === Example  ===
    19 <code language="lua">
    20 function onParameters()
    21     parseParams()
    22     if params["myparam1"] == "hello" then
    23         WriteLnToConsole("Hello World!")
    24     end
    25 end</code>
    27 If the key-value pair `myparam1=hello` is present, this script writes “Hello World!” in the console. All these inputs would trigger the event:
    29 <code>myparam1=hello</code>
    30 <code>myparam2=whatever, myparam1=hello</code>
    31 <code>g=4, f=56, m=56, myparam1=hello</code>