HedgeEditor: Proper error handling when attempting to delete hedgehogs
authorWuzzy <almikes@aol.com>
Mon, 18 Apr 2016 22:34:39 +0200
changeset 12021 c7c0be04ee36
parent 12020 da843fffe020
child 12022 34fdc3d70aca
HedgeEditor: Proper error handling when attempting to delete hedgehogs
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Apr 18 22:25:56 2016 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Apr 18 22:34:39 2016 +0200
@@ -1209,10 +1209,14 @@
 			end
 		elseif pMode[pIndex] == loc("Deletion Mode") then
 			sGear = GetClosestGear()
-			if (sGear ~= nil) and (GetGearType(sGear) ~= gtHedgehog) then
+			if (sGear == nil) then
+				AddCaption(loc("Please click on a gear."),0xffba00ff,capgrpVolume)
+			elseif (GetGearType(sGear) == gtHedgehog) then
+				AddCaption(loc("Hedgehogs can not be deleted."),0xffba00ff,capgrpVolume)
+			else
 				DeleteGear(sGear)
-				sGear = nil
 			end
+			sGear = nil
 		end
 
 	elseif (cat[cIndex] == loc("Hog Identity Mode")) or (cat[cIndex] == loc("Team Identity Mode")) then