Update SetTag, add GetTag.
authoralmikes@aol.com
Wed, 03 Dec 2014 16:17:35 +0000
changeset 419 861e9e89e19c
parent 418 a7d34a3e5786
child 420 55be67135696
Update SetTag, add GetTag.
LuaAPI.wiki
--- a/LuaAPI.wiki	Wed Dec 03 06:45:26 2014 +0000
+++ b/LuaAPI.wiki	Wed Dec 03 16:17:35 2014 +0000
@@ -467,6 +467,24 @@
 
 <blockquote>returns the message of the gear.
 </blockquote>
+
+=== <tt>!GetTag(gearUid)</tt> ===
+
+Returns the tag of the specified gear (by `gearUid`). 
+
+A “tag” of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for gtBall gears, it specifies the ball color, for gtAirAttack gears (airplane) it specifies the direction of the plane, etc. `tag` has to be an integer.
+
+Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
+
+<code language="lua">
+-- This adds a ball (the one from the ballgun) at (123, 456):
+ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
+-- The tag of a ball defines its color. It will automatically chosen at random when created.
+colorTag = GetTag(ball)
+-- Now colorTag stores the tag of ball (in this case a number denoting its color)
+</code>
+
+
 === <tt>!GetFollowGear()</tt> ===
 
 <blockquote>Returns the uid of the gear that is currently being followed.
@@ -706,8 +724,18 @@
 
 === <tt>!SetTag(gearUid, tag)</tt> ===
 
-<blockquote>Sets the tag of the specified gear, different for every gear.
-</blockquote>
+Sets the tag of the specified gear (by `gearUid`). A “tag” of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for gtBall gears, it specifies the ball color, for gtAirAttack gears (airplane) it specifies the direction of the plane, etc. `tag` has to be an integer.
+
+Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. 
+
+<code language="lua">
+-- This adds a ball (the one from the ballgun) at (123, 456):
+ball = AddGear(123, 456, gtBall, 0, 0, 0, 0)
+-- This sets the tag of the gear. For gtBall, the tag specified the color. “8” is the color white.
+SetTag(ball, 8) -- 
+</code>
+
+Extensive documentation on what the different tags for gear types mean is still pending.
 
 === <tt>!SetTimer(gearUid, timer)</tt> ===