# HG changeset patch # User smxx # Date 1272220688 0 # Node ID 791fa466420960ff342f1011f9836dbf60a70974 # Parent 8eb7ea4a9705a19376ade79c5a76b4c90bdac1f6 Engine: * Added backward compatibility to Lua's SetAmmo (now accepts 4 or 5 parameters) diff -r 8eb7ea4a9705 -r 791fa4664209 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; ///////////////////