hedgewars/uScript.pas
changeset 4481 0d73e7db3d59
parent 4456 b69f43f07cd7
child 4483 ad1524a177bd
--- a/hedgewars/uScript.pas	Tue Dec 07 17:33:11 2010 -0500
+++ b/hedgewars/uScript.pas	Tue Dec 07 19:33:34 2010 -0500
@@ -645,6 +645,22 @@
     lc_hogsay:= 0
 end;
 
+function lc_addammo(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if (gear <> nil) and (gear^.Hedgehog <> nil) then
+            AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)));
+        end;
+    lc_addammo:= 0
+end;
+
 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
 begin
@@ -1325,6 +1341,7 @@
 lua_register(luaState, 'PlaySound', @lc_playsound);
 lua_register(luaState, 'AddTeam', @lc_addteam);
 lua_register(luaState, 'AddHog', @lc_addhog);
+lua_register(luaState, 'AddAmmo', @lc_addammo);
 lua_register(luaState, 'SetHealth', @lc_sethealth);
 lua_register(luaState, 'GetHealth', @lc_gethealth);
 lua_register(luaState, 'SetEffect', @lc_seteffect);