LuaLibraryTracker.wiki
changeset 1368 e073a4197c60
parent 1367 831b860f835d
child 1369 9818052b6fcb
equal deleted inserted replaced
1367:831b860f835d 1368:e073a4197c60
    65 == Helper functions ==
    65 == Helper functions ==
    66 === `getFirstHogOfClan(clan)` ===
    66 === `getFirstHogOfClan(clan)` ===
    67 Returns the first hedgehog (alive or not) in the clan with clan ID `clan`.
    67 Returns the first hedgehog (alive or not) in the clan with clan ID `clan`.
    68 
    68 
    69 == Key-value storage ==
    69 == Key-value storage ==
    70 For tracked gears, teams and clans, you can assign an arbitrary number of values. Each tracked object will have a simple key-value storage. Any data type (besides `nil`) can be used for keys and values. Initially, all keys have the value `nil`.
    70 For tracked gears, teams and clans, you can assign an arbitrary number of values. Each tracked object has a simple key-value storage. This means, a tracked object has an arbitrary number of keys, each of which holds one arbitrary value. Any data type (besides `nil`) can be used for keys and values. Initially, all keys have the value `nil`.
    71 
    71 
    72 === `getGearValue(gear, key)` ===
    72 === `getGearValue(gear, key)` ===
    73 Returns the gear value of the given `gear` for `key`.
    73 Returns the gear value of the given `gear` for `key`.
    74 
    74 
    75 === `setGearValue(gear, key, value)` ===
    75 === `setGearValue(gear, key, value)` ===
   102 === `increaseClanValue(clan, key)` ===
   102 === `increaseClanValue(clan, key)` ===
   103 Increases the clan value for `key` by 1. `clan` is the clan ID. This function *must not* be called if the current value is not a number.
   103 Increases the clan value for `key` by 1. `clan` is the clan ID. This function *must not* be called if the current value is not a number.
   104 
   104 
   105 === `decreaseClanValue(clan, key)` ===
   105 === `decreaseClanValue(clan, key)` ===
   106 Decreases the clan value for `key` by 1. `clan` is the clan ID. This function *must not* be called if the current value is not a number.
   106 Decreases the clan value for `key` by 1. `clan` is the clan ID. This function *must not* be called if the current value is not a number.
       
   107 
       
   108 === Examples ===
       
   109 Assuming `gear` is a tracked gear, here are some simple usage examples:
       
   110 
       
   111 <code lang="lua">
       
   112 setGearValue(gear, "mutant", true)
       
   113 local isMutant = getGearValue(gear, "mutant")
       
   114 print(isMutant) -- prints "true"
       
   115 </code>
       
   116 
       
   117 <code lang="lua">
       
   118 setGearValue(gear, "score", 0)
       
   119 increaseGearValue(gear, "score")
       
   120 local score = getGearValue(gear, "score")
       
   121 print(score) -- prints "1"
       
   122 </code>