share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 11983 9e57915f5365
parent 11946 65e61f495129
child 11984 ad38e2c7ab12
--- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Wed Nov 23 00:28:58 2016 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Wed Nov 23 01:05:34 2016 +0100
@@ -558,7 +558,8 @@
         SetAmmoTexts(amAirAttack, loc("Place waypoint"), loc("Racer tool"),
                 loc("Build an awesome race track by placing|waypoints which the hedgehogs have to|touch in any order to finish a round.") .. "|" ..
 		loc("Hedgehogs will start in the first waypoint.") .. "|" ..
- 		loc("Cursor: Place waypoint"))
+ 		loc("Cursor: Place waypoint") .. "|" ..
+ 		loc("Precise: Remove previous waypoint"))
 
         SetAmmoTexts(amSkip, loc("Finish waypoint placement"), loc("Racer tool"),
                 loc("Happy with your race track?|Then stop building and start racing!") .. "|" ..
@@ -587,6 +588,27 @@
     end
 end
 
+function onPrecise()
+    if not racerActive and CurrentHedgehog ~= nil and GetCurAmmoType() == amAirAttack then
+        DeletePreviousWayPoint()
+    end
+end
+
+function DeletePreviousWayPoint()
+    if wpCount > 0 then
+        wpCount = wpCount - 1
+        wpX[wpCount] = nil
+        wpY[wpCount] = nil
+        wpCol[wpCount] = nil
+        DeleteVisualGear(wpCirc[wpCount])
+        wpCirc[wpCount] = nil
+        AddCaption(string.format(loc("Waypoint removed. Available points: %d"), wpLimit-wpCount))
+    else
+        PlaySound(sndDenied)
+        AddCaption(loc("No waypoint to be removed!"))
+    end
+end
+
 function onSpecialPoint(x,y,flag)
     if flag == 99 then
         fastX[fastCount] = x