hedgewars/uScript.pas
changeset 7439 0a494f951dcf
parent 7426 55b49cc1f33a
child 7517 f287f00063e8
equal deleted inserted replaced
7358:57a508884052 7439:0a494f951dcf
   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;
   976 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence.
   979 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence.
   977         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then
   980         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then
   978             begin
   981             begin
   979             prevgear := CurrentHedgehog^.Gear;
   982             prevgear := CurrentHedgehog^.Gear;
   980             prevgear^.Active := false;
   983             prevgear^.Active := false;
   981             prevgear^.State:= prevgear^.State and not gstHHDriven;
   984             prevgear^.State:= prevgear^.State and (not gstHHDriven);
   982             prevgear^.Z := cHHZ;
   985             prevgear^.Z := cHHZ;
   983             RemoveGearFromList(prevgear);
   986             prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList;
   984             InsertGearToList(prevgear);
       
   985             
   987             
   986             SwitchCurrentHedgehog(gear^.Hedgehog);
   988             SwitchCurrentHedgehog(gear^.Hedgehog);
   987             CurrentTeam:= CurrentHedgehog^.Team;
   989             CurrentTeam:= CurrentHedgehog^.Team;
   988 
   990 
   989             gear^.State:= gear^.State or gstHHDriven;
   991             gear^.State:= gear^.State or gstHHDriven;
   990             gear^.Active := true;
   992             gear^.Active := true;
   991             gear^.Z := cCurrHHZ;
   993             gear^.Z := cCurrHHZ;
   992             RemoveGearFromList(gear);
   994             gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList;
   993             InsertGearToList(gear);
       
   994             end
   995             end
   995         end;
   996         end;
   996     lc_switchhog:= 0
   997     lc_switchhog:= 0
   997 end;
   998 end;
   998 
   999