hedgewars/uScript.pas
changeset 7337 c224cd2d32f3
parent 7307 f830a65d6a6d
child 7339 5984b749ad9b
equal deleted inserted replaced
7335:3c6f08af7dac 7337:c224cd2d32f3
   320         begin
   320         begin
   321         if lua_gettop(L) = 3 then
   321         if lua_gettop(L) = 3 then
   322             health:= lua_tointeger(L, 3)
   322             health:= lua_tointeger(L, 3)
   323         else
   323         else
   324             health:= cHealthCaseAmount;
   324             health:= cHealthCaseAmount;
   325         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health);
   325         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0);
   326         if gear <> nil then
   326         if gear <> nil then
   327             lua_pushinteger(L, gear^.uid)
   327             lua_pushinteger(L, gear^.uid)
   328         else
   328         else
   329             lua_pushnil(L);
   329             lua_pushnil(L);
   330         end;
   330         end;
   332 end;
   332 end;
   333 
   333 
   334 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
   334 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
   335 var gear: PGear;
   335 var gear: PGear;
   336 begin
   336 begin
   337     if lua_gettop(L) <> 3 then
   337     if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then
   338         begin
   338         begin
   339         LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
   339         LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
   340         lua_pushnil(L);
   340         lua_pushnil(L);
   341         end
   341         end
   342     else
   342     else
   343         begin
   343         begin
   344         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3));
   344         if (lua_gettop(L) <> 3) then 
       
   345              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0)
       
   346         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   345         if gear <> nil then
   347         if gear <> nil then
   346             lua_pushinteger(L, gear^.uid)
   348             lua_pushinteger(L, gear^.uid)
   347         else
   349         else
   348             lua_pushnil(L);
   350             lua_pushnil(L);
   349         end;
   351         end;
   351 end;
   353 end;
   352 
   354 
   353 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
   355 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
   354 var gear: PGear;
   356 var gear: PGear;
   355 begin
   357 begin
   356     if lua_gettop(L) <> 3 then
   358     if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then
   357         begin
   359         begin
   358         LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
   360         LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
   359         lua_pushnil(L);
   361         lua_pushnil(L);
   360         end
   362         end
   361     else
   363     else
   362         begin  
   364         begin
   363         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   365         if (lua_gettop(L) <> 3) then
   364         UtilityCrate, lua_tointeger(L, 3));
   366              gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0)
       
   367         else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4));
   365         if gear <> nil then
   368         if gear <> nil then
   366             lua_pushinteger(L, gear^.uid)
   369             lua_pushinteger(L, gear^.uid)
   367         else
   370         else
   368             lua_pushnil(L);
   371             lua_pushnil(L);
   369        end;
   372        end;