add nil check
authornemo
Sat, 04 Dec 2010 15:09:19 -0500
changeset 4456 b69f43f07cd7
parent 4455 a0c8779713f2
child 4459 6de30ddc184e
add nil check
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sat Dec 04 11:30:54 2010 -0500
+++ b/hedgewars/uScript.pas	Sat Dec 04 15:09:19 2010 -0500
@@ -263,7 +263,8 @@
         c:= lua_toboolean(L, 5);
 
         vg:= AddVisualGear(x, y, vgt, s, c); 
-        lua_pushnumber(L, vg^.uid)
+        if vg <> nil then lua_pushnumber(L, vg^.uid)
+        else lua_pushnumber(L, 0)
         end;
     lc_addvisualgear:= 1; // 1 return value
 end;