Allow to remove waypoints in Racer with precise key
authorWuzzy <almikes@aol.com>
Wed, 23 Nov 2016 01:05:34 +0100
changeset 11988 9e57915f5365
parent 11987 6f4b96669f9d
child 11989 ad38e2c7ab12
Allow to remove waypoints in Racer with precise key
ChangeLog.txt
share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
--- a/ChangeLog.txt	Wed Nov 23 00:28:58 2016 +0100
+++ b/ChangeLog.txt	Wed Nov 23 01:05:34 2016 +0100
@@ -51,6 +51,7 @@
  + Capture The Flag supports setting number of captures with script parameter “capture=<number>”
  + Show correct ranking and times in stats screen of Racer and TechRacer
  + Allow to only place 2 waypoints in Racer
+ + Allow to remove Racer waypoints with precise key
  + New script parameter “waypointradius=<number>” for Racer set the size of waypoints
  * Fixed waypoint message in TechRacer and Racer overwriting current weapon selection message
  * Fixed TechRacer not recording finish if time was >= 100s
--- 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