LuaLibraryAnimate: Explain BlowHog example better
authorWuzzy
Wed, 21 Jun 2023 13:33:14 +0000
changeset 2246 9cee5aab336d
parent 2245 3e97c75aaddc
child 2247 fdd314eb697f
LuaLibraryAnimate: Explain BlowHog example better
LuaLibraryAnimate.wiki
--- a/LuaLibraryAnimate.wiki	Wed Jun 21 13:10:24 2023 +0000
+++ b/LuaLibraryAnimate.wiki	Wed Jun 21 13:33:14 2023 +0000
@@ -86,19 +86,21 @@
 Inserts `step` after the current step (read: action) in the cinematic array. Useful when an action depends on variables (e.g. positions). It can be used mostly with `AnimCustomFunction`. Note: In case of multiple consecutive calls, steps need to be added in reverse order.
 
 Example:
-<code language="lua">function BlowHog(deadHog)
-  AnimInsertStepNext({func = DeleteGear, args = {deadHog}, swh = false})
-  AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog), GetY(deadHog), vgtBigExplosion, 0, true}, swh = false})
-  AnimInsertStepNext({func = AnimWait, args = {deadHog, 1200}})
-  AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
-  AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
-  AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
-  AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
-  AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
-  AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
-  AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
+<code language="lua">-- Show explosion effects around hedgehog `liveHog`, then delete it
+function BlowHog(deadHog)
+    AnimInsertStepNext({func = DeleteGear, args = {deadHog}, swh = false})
+    AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog), GetY(deadHog), vgtBigExplosion, 0, true}, swh = false})
+    AnimInsertStepNext({func = AnimWait, args = {deadHog, 1200}})
+    AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
+    AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
+    AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
+    AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
+    AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
+    AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}})
+    AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false})
 end
-cinem = {{func = AnimCustomFunction, args = {liveHog, BlowHog, {deadHog}}}}</code>
+cinem = {{func = AnimCustomFunction, args = {liveHog, BlowHog, {deadHog}}}}
+AddAnim(cinem)</code>
 
 ==== `ShowAnimation()` ====
 Performs the current action in the cinematic and returns `true` if finished, otherwise `false`. It needs to be used in `onGameTick`. Cut-scenes need to be added with `AddAnim(steps)`.