Engine:
authorsmxx
Sun, 25 Apr 2010 18:38:08 +0000
changeset 3368 791fa4664209
parent 3367 8eb7ea4a9705
child 3369 c7289e42f0ee
Engine: * Added backward compatibility to Lua's SetAmmo (now accepts 4 or 5 parameters)
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sun Apr 25 13:54:45 2010 +0000
+++ b/hedgewars/uScript.pas	Sun Apr 25 18:38:08 2010 +0000
@@ -484,13 +484,15 @@
 end;
 
 function lc_setammo(L : Plua_State) : LongInt; Cdecl;
+var np: LongInt;
 begin
-    if lua_gettop(L) <> 5 then
+    np:= lua_gettop(L);
+    if (np < 4) or (np > 5) then
         WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!')
+    else if np = 4 then
+        ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1)
     else
-        begin
         ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
-        end;
     lc_setammo:= 0
 end;
 ///////////////////