hedgewars/uScript.pas
changeset 11251 66796cd627d8
parent 11196 f4cf2cdea8e5
child 11317 62287d4044e7
child 12366 744e51920a04
equal deleted inserted replaced
11249:ead06147f84d 11251:66796cd627d8
   642 begin
   642 begin
   643     if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then
   643     if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then
   644         begin
   644         begin
   645         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   645         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   646         AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
   646         AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
   647         lua_pushinteger(L, gear^.uid);
   647         if gear <> nil then
       
   648              lua_pushinteger(L, gear^.uid)
       
   649         else lua_pushnil(L)
   648         end
   650         end
   649     else
   651     else
   650         lua_pushnil(L);
   652         lua_pushnil(L);
   651     lc_spawnfakeammocrate := 1;
   653     lc_spawnfakeammocrate := 1;
   652 end;
   654 end;
   656 begin
   658 begin
   657     if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then
   659     if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then
   658         begin
   660         begin
   659         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   661         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   660         UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
   662         UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
   661         lua_pushinteger(L, gear^.uid);
   663         if gear <> nil then
       
   664              lua_pushinteger(L, gear^.uid)
       
   665         else lua_pushnil(L)
   662         end
   666         end
   663     else
   667     else
   664         lua_pushnil(L);
   668         lua_pushnil(L);
   665     lc_spawnfakeutilitycrate := 1;
   669     lc_spawnfakeutilitycrate := 1;
   666 end;
   670 end;
   675             health:= lua_tointeger(L, 3)
   679             health:= lua_tointeger(L, 3)
   676         else
   680         else
   677             health:= cHealthCaseAmount;
   681             health:= cHealthCaseAmount;
   678         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0);
   682         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0);
   679         if gear <> nil then
   683         if gear <> nil then
   680             lua_pushinteger(L, gear^.uid)
   684              lua_pushinteger(L, gear^.uid)
   681         else
   685         else lua_pushnil(L);
   682             lua_pushnil(L);
       
   683         end
   686         end
   684     else
   687     else
   685         lua_pushnil(L);
   688         lua_pushnil(L);
   686     lc_spawnhealthcrate := 1;
   689     lc_spawnhealthcrate := 1;
   687 end;
   690 end;
   694         begin
   697         begin
   695         if n = 3 then
   698         if n = 3 then
   696              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0)
   699              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0)
   697         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   700         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   698         if gear <> nil then
   701         if gear <> nil then
   699             lua_pushinteger(L, gear^.uid)
   702              lua_pushinteger(L, gear^.uid)
   700         else
   703         else lua_pushnil(L);
   701             lua_pushnil(L);
       
   702         end
   704         end
   703     else
   705     else
   704         lua_pushnil(L);
   706         lua_pushnil(L);
   705     lc_spawnammocrate := 1;
   707     lc_spawnammocrate := 1;
   706 end;
   708 end;
   713         begin
   715         begin
   714         if n = 3 then
   716         if n = 3 then
   715              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0)
   717              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0)
   716         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   718         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   717         if gear <> nil then
   719         if gear <> nil then
   718             lua_pushinteger(L, gear^.uid)
   720              lua_pushinteger(L, gear^.uid)
   719         else
   721         else lua_pushnil(L);
   720             lua_pushnil(L);
       
   721        end
   722        end
   722     else
   723     else
   723         lua_pushnil(L);
   724         lua_pushnil(L);
   724     lc_spawnutilitycrate := 1;
   725     lc_spawnutilitycrate := 1;
   725 end;
   726 end;