LuaLibraries.wiki
changeset 526 f910cf3241fc
parent 525 b051cfd45c23
child 527 908428bf4a03
equal deleted inserted replaced
525:b051cfd45c23 526:f910cf3241fc
   307 RemoveEventFunc(condFunc1) --Removes all three events that have condFunc1
   307 RemoveEventFunc(condFunc1) --Removes all three events that have condFunc1
   308 RemoveEventFunc(condFunc2, condArgs1) --Removes a single event</code>
   308 RemoveEventFunc(condFunc2, condArgs1) --Removes a single event</code>
   309 
   309 
   310 === !CheckEvents ===
   310 === !CheckEvents ===
   311 <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>
   311 <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>
       
   312 
       
   313 
       
   314 = Params =
       
   315 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.
       
   316 
       
   317 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:
       
   318 {{{
       
   319 speed=1
       
   320 health=100, ammo=5
       
   321 param1=hello, param2=whatever, param3=5325.4
       
   322 }}}
       
   323 
       
   324 Using this library is by no means neccessary.
       
   325 
       
   326 == `parseParams()` ==
       
   327 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.
       
   328 
       
   329 === Example  ===
       
   330 <code language="lua">
       
   331 function onParameters()
       
   332     parseParams()
       
   333     if params["myparam1"] == "hello" then
       
   334         WriteLnToConsole("Hello World!")
       
   335     end
       
   336 end
       
   337 </code>
       
   338 
       
   339 If the key-value pair `myparam1=hello` is present, this script writes “Hello World!” in the console. All these inputs would trigger the event:
       
   340 
       
   341 {{{
       
   342 myparam1=hello
       
   343 myparam2=whatever, myparam1=hello
       
   344 g=4, f=56, m=56, myparam1=hello
       
   345 }}}