Add callback: onEndTurn
authorWuzzy <Wuzzy2@mail.ru>
Thu, 08 Feb 2018 18:10:39 +0100
changeset 12928 fa402ce826c2
parent 12927 9400a272c88f
child 12929 1d7d7d21914a
Add callback: onEndTurn
ChangeLog.txt
hedgewars/uGears.pas
--- a/ChangeLog.txt	Thu Feb 08 15:44:08 2018 +0100
+++ b/ChangeLog.txt	Thu Feb 08 18:10:39 2018 +0100
@@ -29,6 +29,7 @@
 
 Lua API:
  + New call: WriteLnToChat(string): Add a line in the chat
+ + New callback: onEndTurn(): Called at the end of a turn (when gears have settled)
  * Fix call: SetWeapon(amNothing) now unselects weapon
  * Fix global: TotalRounds was stuck at -1 for several turns
 
--- a/hedgewars/uGears.pas	Thu Feb 08 15:44:08 2018 +0100
+++ b/hedgewars/uGears.pas	Thu Feb 08 18:10:39 2018 +0100
@@ -62,7 +62,7 @@
 
 var delay: LongWord;
     delay2: LongWord;
-    step: (stDelay, stChDmg, stSweep, stTurnReact,
+    step: (stInit, stDelay, stChDmg, stSweep, stTurnReact,
     stAfterDelay, stChWin, stWater, stChWin2, stHealth,
     stSpawn, stNTurn);
     NewTurnTick: LongWord;
@@ -253,6 +253,11 @@
 
 if AllInactive then
 case step of
+    stInit:
+        begin
+        ScriptCall('onEndTurn');
+        inc(step)
+        end;
     stDelay:
         begin
         if delay = 0 then