HedgeEditor: Fix girder/rubber mods sometimes show nil in 2nd message
authorWuzzy <almikes@aol.com>
Mon, 18 Apr 2016 22:25:56 +0200
changeset 12020 da843fffe020
parent 12019 67b18844e3bb
child 12021 c7c0be04ee36
HedgeEditor: Fix girder/rubber mods sometimes show nil in 2nd message
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Apr 18 22:12:50 2016 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Apr 18 22:25:56 2016 +0200
@@ -2946,13 +2946,7 @@
 			-- update display selection criteria
 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
 				AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
-				local caption2
-				if type(pMode[pIndex]) == "table" then
-					caption2 = tostring(pMode[pIndex][1])
-				else
-					caption2 = tostring(pMode[pIndex])
-				end
-				AddCaption(caption2,0xffba00ff,capgrpMessage2)
+				showSecondaryMessage()
 				if superDelete == true then
 					AddCaption(loc("Warning: Deletition Mode Active"),0xffba00ff,capgrpAmmoinfo)
 				end
@@ -3087,6 +3081,20 @@
 	preciseOn = false
 end
 
+function showSecondaryMessage()
+	local caption2
+	if type(pMode[pIndex]) == "table" then
+		caption2 = tostring(pMode[pIndex][1])
+	elseif curWep == amGirder then
+		caption2 = loc("Girder")
+	elseif curWep == amRubber then
+		caption2 = loc("Rubber")
+	else
+		caption2 = tostring(pMode[pIndex])
+	end
+	AddCaption(caption2, 0xffba00ff, capgrpMessage2)
+end
+
 ---------------------------------------------------------------
 -- Cycle through selection subsets (by changing pIndex, pMode)
 -- i.e 	health of barrels, medikits,
@@ -3115,7 +3123,7 @@
 		end
 
 		if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
-			AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
+			showSecondaryMessage()
 		end
 	end
 
@@ -3143,7 +3151,7 @@
 		end
 	
 		if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
-			AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
+			showSecondaryMessage()
 		end
 	end