Added a non-exhaustive list of examples for further applications of SetHealth()
authorRedGrinner@gmail.com
Thu, 24 Mar 2011 13:03:30 +0000
changeset 99 983ec9ac63c7
parent 98 54e178bb6986
child 100 1671c5c8961a
Added a non-exhaustive list of examples for further applications of SetHealth()
LuaAPI.wiki
--- a/LuaAPI.wiki	Thu Mar 24 12:43:03 2011 +0000
+++ b/LuaAPI.wiki	Thu Mar 24 13:03:30 2011 +0000
@@ -340,6 +340,29 @@
 === <tt>!SetHealth(gearUid, health)</tt> ===
 
 <blockquote>Sets the health of the specified gear.
+This can be used for purposes other than killing hedgehogs.
+
+For example:
+
+  * Starting the RC Plane 10 shots
+  * Starting Flying Saucer (gtJetpack) with only 50% fuel.
+  * Setting all the mines to duds.
+  * (And more!)
+
+<code lang="lua">    function onGearAdd(gear)
+       if (!GetGearType(gear) == gtRCPlane) then
+            !SetHealth(gear, 10)
+       end
+       if (!GetGearType(gear) == gtJetpack) then
+            !SetHealth(gear, 1000)
+       end
+       if (!GetGearType(gear) == gtMine) then
+            !SetHealth(gear, 0)
+       end
+    end</code>
+
+
+
 </blockquote>
 === <tt>!SetEffect(gearUid, effect, true/false)</tt> (0.9.14 / dev) ===