TrophyRace: Show current racing time at top
authorWuzzy <Wuzzy2@mail.ru>
Thu, 15 Feb 2018 16:48:04 +0100
changeset 13008 99ff8f4810f4
parent 13007 8a8aaaf97a95
child 13009 67cc3cac4c8e
TrophyRace: Show current racing time at top
share/hedgewars/Data/Maps/TrophyRace/map.lua
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua	Thu Feb 15 13:49:14 2018 +0100
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua	Thu Feb 15 16:48:04 2018 +0100
@@ -125,6 +125,7 @@
     end
     if CurrentHedgehog ~= nil and TurnTimeLeft == 1 then
         killHog()
+        AddCaption(loc("Time's up!"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
     elseif CurrentHedgehog ~= nil then
         x, y = GetGearPosition(CurrentHedgehog)
         if not reached and x > goal_area[1] and x < goal_area[1] + goal_area[3] and y > goal_area[2] and y < goal_area[2] + goal_area[4] then -- hog is within goal rectangle
@@ -185,8 +186,15 @@
                 hscore = hscore .. "|" .. string.format(loc("Team %d: "), i+1) .. tt
             end
             
-            ShowMission(loc("TrophyRace"), loc("Race"), loc("You've reached the goal!| |Time: ") .. (ttime / 1000) .. " s" .. hscore, 0, 0)
+            local strtime = string.format(loc("Time: %.3fs"), (ttime/1000))
+            ShowMission(loc("TrophyRace"), loc("Race"), loc("You've reached the goal!") .. "| |" .. strtime .. hscore, 0, 0)
+            AddCaption(strtime, GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
             EndTurn(true)
+        else
+            if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and CurrentHedgehog ~= nil and GetHealth(CurrentHedgehog) > 0 and (not reached) and GameTime%100 == 0 then
+                local ttime = GameTime-startTime
+                AddCaption(string.format(loc("Time: %.1fs"), (ttime/1000)), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
+            end
         end
     end
 end