Lua library Animate: StoppedGear now returns true if gear does not exist
authorWuzzy <Wuzzy2@mail.ru>
Mon, 19 Feb 2018 09:45:36 +0100
changeset 13037 91f23558c936
parent 13036 bef97cc310b0
child 13038 a823de31240e
Lua library Animate: StoppedGear now returns true if gear does not exist Fixes Lua error spam in ACF1 when Leaks a Lot drows
ChangeLog.txt
share/hedgewars/Data/Scripts/Animate.lua
--- a/ChangeLog.txt	Sat Feb 17 20:59:56 2018 +0100
+++ b/ChangeLog.txt	Mon Feb 19 09:45:36 2018 +0100
@@ -53,6 +53,7 @@
 A Classic Fairytale:
  + Mission 3: Display number of turns left at timed parcours
  * Fix incorrect storytelling in mission descriptions
+ * Mission 1: Fix error message spam when Leaks a Lot drowns
 
 Theme customization:
  + Add fallback music with fallback-music and fallback-sd-music
--- a/share/hedgewars/Data/Scripts/Animate.lua	Sat Feb 17 20:59:56 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Mon Feb 19 09:45:36 2018 +0100
@@ -425,6 +425,11 @@
 -------------------------------------Misc---------------------------------
 
 function StoppedGear(gear)
+  -- GetHealth returns nil if gear does not exist
+  if not GetHealth(gear) then
+     -- We consider the gear to be “stopped” if it has been destroyed
+     return true
+  end
   dx,dy = GetGearVelocity(gear)
   return math.abs(dx) <= 1 and math.abs(dy) <= 1
 end