hedgewars/uScript.pas
changeset 3750 3aa85b5f3318
parent 3736 d8982f9e7e2c
child 3755 02dc9fcb6477
equal deleted inserted replaced
3749:d0920e92008e 3750:3aa85b5f3318
   116     HideMission;
   116     HideMission;
   117     lc_hidemission:= 0;
   117     lc_hidemission:= 0;
   118 end;
   118 end;
   119 
   119 
   120 function lc_spawnhealthcrate(L: Plua_State) : LongInt; Cdecl;
   120 function lc_spawnhealthcrate(L: Plua_State) : LongInt; Cdecl;
       
   121 var gear: PGear;
   121 begin
   122 begin
   122     if lua_gettop(L) <> 2 then begin
   123     if lua_gettop(L) <> 2 then begin
   123         LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!');
   124         LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!');
   124         lua_pushnil(L);
   125         lua_pushnil(L);
   125     end
   126     end
   126     else begin
   127     else begin
   127         SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   128         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   128             HealthCrate, 0);
   129             HealthCrate, 0);
       
   130         lua_pushnumber(L, gear^.uid);
   129     end;
   131     end;
   130     lc_spawnhealthcrate := 1;        
   132     lc_spawnhealthcrate := 1;        
   131 end;
   133 end;
   132 
   134 
   133 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
   135 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
       
   136 var gear: PGear;
   134 begin
   137 begin
   135     if lua_gettop(L) <> 3 then begin
   138     if lua_gettop(L) <> 3 then begin
   136         LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
   139         LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
   137         lua_pushnil(L);
   140         lua_pushnil(L);
   138     end
   141     end
   139     else begin
   142     else begin
   140         SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   143         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   141             AmmoCrate, lua_tointeger(L, 3));
   144             AmmoCrate, lua_tointeger(L, 3));
       
   145         lua_pushnumber(L, gear^.uid);
   142     end;
   146     end;
   143     lc_spawnammocrate := 1;
   147     lc_spawnammocrate := 1;
   144 end;
   148 end;
   145 
   149 
   146 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
   150 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
       
   151 var gear: PGear;
   147 begin
   152 begin
   148     if lua_gettop(L) <> 3 then begin
   153     if lua_gettop(L) <> 3 then begin
   149         LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
   154         LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
   150         lua_pushnil(L);
   155         lua_pushnil(L);
   151     end
   156     end
   152     else begin  
   157     else begin  
   153         SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   158         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   154             UtilityCrate, lua_tointeger(L, 3));
   159             UtilityCrate, lua_tointeger(L, 3));
       
   160         lua_pushnumber(L, gear^.uid);
   155     end;
   161     end;
   156     lc_spawnutilitycrate := 1;
   162     lc_spawnutilitycrate := 1;
   157 end;
   163 end;
   158 
   164 
   159 function lc_addgear(L : Plua_State) : LongInt; Cdecl;
   165 function lc_addgear(L : Plua_State) : LongInt; Cdecl;