LuaLibraryTracker: Add examples
authorWuzzy
Wed, 02 May 2018 23:52:00 +0100
changeset 1368 e073a4197c60
parent 1367 831b860f835d
child 1369 9818052b6fcb
LuaLibraryTracker: Add examples
LuaLibraryTracker.wiki
--- a/LuaLibraryTracker.wiki	Wed May 02 23:47:34 2018 +0100
+++ b/LuaLibraryTracker.wiki	Wed May 02 23:52:00 2018 +0100
@@ -67,7 +67,7 @@
 Returns the first hedgehog (alive or not) in the clan with clan ID `clan`.
 
 == Key-value storage ==
-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`.
+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`.
 
 === `getGearValue(gear, key)` ===
 Returns the gear value of the given `gear` for `key`.
@@ -104,3 +104,19 @@
 
 === `decreaseClanValue(clan, key)` ===
 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.
+
+=== Examples ===
+Assuming `gear` is a tracked gear, here are some simple usage examples:
+
+<code lang="lua">
+setGearValue(gear, "mutant", true)
+local isMutant = getGearValue(gear, "mutant")
+print(isMutant) -- prints "true"
+</code>
+
+<code lang="lua">
+setGearValue(gear, "score", 0)
+increaseGearValue(gear, "score")
+local score = getGearValue(gear, "score")
+print(score) -- prints "1"
+</code>
\ No newline at end of file