Add Lua callback: onGameResult
authorWuzzy <Wuzzy2@mail.ru>
Tue, 18 Dec 2018 18:26:13 +0100
changeset 14465 ca851d0957cf
parent 14464 ead8928a59f8
child 14466 734a7af2dfc2
Add Lua callback: onGameResult
ChangeLog.txt
hedgewars/uStats.pas
--- a/ChangeLog.txt	Tue Dec 18 18:16:31 2018 +0100
+++ b/ChangeLog.txt	Tue Dec 18 18:26:13 2018 +0100
@@ -20,6 +20,7 @@
  + New call: GetMissionVar(varname): Get value of mission variable
  + New call: SetTurnTimePaused(isPaused): Call with true to pause turn time, false to unpause
  + New call: GetTurnTimePaused(): Returns true if turn time is paused due to Lua
+ + New callback: onGameResult(winningClan): Called when the game ends normally. winningClan = index of winning clan or -1 on draw
  + Params explode, poison in the SpawnFake*Crate functions now optional and default to false
 
 ====================== 0.9.25 ======================
--- a/hedgewars/uStats.pas	Tue Dec 18 18:16:31 2018 +0100
+++ b/hedgewars/uStats.pas	Tue Dec 18 18:26:13 2018 +0100
@@ -553,13 +553,17 @@
     // now to console
     if winnersClan <> nil then
         begin
+        ScriptCall('onGameResult', winnersClan^.ClanIndex);
         WriteLnToConsole('WINNERS');
         WriteLnToConsole(inttostr(winnersClan^.TeamsNumber));
         for t:= 0 to winnersClan^.TeamsNumber - 1 do
             WriteLnToConsole(winnersClan^.Teams[t]^.TeamName);
         end
     else
+        begin
+        ScriptCall('onGameResult', -1);
         WriteLnToConsole('DRAW');
+        end;
 
     ScriptCall('onAchievementsDeclaration');
 end;