return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
authornemo
Tue, 28 Dec 2010 19:32:21 -0500
changeset 4767 4ee4a49549e2
parent 4764 674cdcf8b661
child 4770 375d819fca93
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
hedgewars/uScript.pas
share/hedgewars/Data/Maps/Control/map.lua
--- a/hedgewars/uScript.pas	Tue Dec 28 19:20:30 2010 -0500
+++ b/hedgewars/uScript.pas	Tue Dec 28 19:32:21 2010 -0500
@@ -358,6 +358,11 @@
             lua_pushinteger(L, vg^.Timer);
             lua_pushinteger(L, vg^.Tint);
             end
+        else
+            begin
+            lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L);
+            lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L)
+            end
         end;
     lc_getvisualgearvalues:= 10;
 end;
--- a/share/hedgewars/Data/Maps/Control/map.lua	Tue Dec 28 19:20:30 2010 -0500
+++ b/share/hedgewars/Data/Maps/Control/map.lua	Tue Dec 28 19:32:21 2010 -0500
@@ -200,7 +200,9 @@
 		if CurrentHedgehog ~= nil then		
 			if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
 				g = AddVisualGear(vCircX[i], vCircY[i], vgtHealthTag, 100, False)
-				SetVisualGearValues(g, vCircX[i], vCircY[i], 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
+                if g ~= 0 then
+				    SetVisualGearValues(g, vCircX[i], vCircY[i], 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
+                end
 			end
 		end
 	end