hedgewars/uScript.pas
changeset 5272 a85d331ab5bb
parent 5245 ce407084728f
child 5277 09beef0752ab
equal deleted inserted replaced
5271:48d18e329298 5272:a85d331ab5bb
   852 end;
   852 end;
   853 
   853 
   854 function lc_addammo(L : Plua_State) : LongInt; Cdecl;
   854 function lc_addammo(L : Plua_State) : LongInt; Cdecl;
   855 var gear : PGear;
   855 var gear : PGear;
   856 begin
   856 begin
   857     if lua_gettop(L) <> 2 then
   857     if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then
   858         begin
       
   859         LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
       
   860         end
       
   861     else
       
   862         begin
   858         begin
   863         gear:= GearByUID(lua_tointeger(L, 1));
   859         gear:= GearByUID(lua_tointeger(L, 1));
   864         if (gear <> nil) and (gear^.Hedgehog <> nil) then
   860         if (gear <> nil) and (gear^.Hedgehog <> nil) then
   865             AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)));
   861             if lua_gettop(L) = 2 then AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)))
   866         end;
   862             else AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3))
       
   863         end
       
   864     else LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
   867     lc_addammo:= 0
   865     lc_addammo:= 0
   868 end;
   866 end;
   869 
   867 
   870 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
   868 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
   871 var gear : PGear;
   869 var gear : PGear;