# HG changeset patch
# User nemo
# Date 1443906177 14400
# Node ID f4cf2cdea8e545b015fb791da9c1b4fe4d53618d
# Parent  283b6e6cf7ea7aa7652dc0f28dd1711da3a62ba7
Add nil check in fake crate spawn for if crate fails to spawn

diff -r 283b6e6cf7ea -r f4cf2cdea8e5 hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Fri Sep 25 23:31:16 2015 -0400
+++ b/hedgewars/uScript.pas	Sat Oct 03 17:02:57 2015 -0400
@@ -628,7 +628,9 @@
         begin
         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
         HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
-        lua_pushinteger(L, gear^.uid);
+        if gear <> nil then
+             lua_pushinteger(L, gear^.uid)
+        else lua_pushnil(L)
         end
     else
         lua_pushnil(L);