# HG changeset patch # User Wuzzy # Date 1544370862 -3600 # Node ID c2cd3f64b9f749b0c79e466e021fe2a11cff52f5 # Parent e335b3120f595d2cf3746648dd771943405af2cd Lua API: Make the last 2 params optional in the SpawnFake*Crate functions diff -r e335b3120f59 -r c2cd3f64b9f7 ChangeLog.txt --- a/ChangeLog.txt Sun Dec 09 04:09:38 2018 +0300 +++ b/ChangeLog.txt Sun Dec 09 16:54:22 2018 +0100 @@ -3,6 +3,9 @@ =============== 1.0.0 (unreleased) ================= + New chat command: “/help room” (shows room chat commands within the game) +Lua API: + + Params explode, poison in the SpawnFake*Crate functions now optional and default to false + ====================== 0.9.25 ====================== HIGHLIGHTS: + Complete overhaul of Continental supplies diff -r e335b3120f59 -r c2cd3f64b9f7 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Dec 09 04:09:38 2018 +0300 +++ b/hedgewars/uScript.pas Sun Dec 09 16:54:22 2018 +0100 @@ -686,11 +686,20 @@ function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; var gear: PGear; -begin - if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then + explode, poison: boolean; + n: LongInt; +begin + if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeHealthCrate', 'x, y [, explode [, poison]]', n) then begin + explode:= false; + poison:= false; + if (n >= 3) and (not lua_isnil(L, 3)) then + explode:= lua_toboolean(L, 3); + if (n = 4) and (not lua_isnil(L, 4)) then + poison:= lua_toboolean(L, 4); + gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), - HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + HealthCrate, explode, poison); if gear <> nil then lua_pushnumber(L, gear^.uid) else lua_pushnil(L) @@ -702,11 +711,20 @@ function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; -begin - if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then + explode, poison: boolean; + n: LongInt; +begin + if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeAmmoCrate', 'x, y [, explode [, poison]]', n) then begin + explode:= false; + poison:= false; + if (n >= 3) and (not lua_isnil(L, 3)) then + explode:= lua_toboolean(L, 3); + if (n = 4) and (not lua_isnil(L, 4)) then + poison:= lua_toboolean(L, 4); + gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), - AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + AmmoCrate, explode, poison); if gear <> nil then lua_pushnumber(L, gear^.uid) else lua_pushnil(L) @@ -718,11 +736,20 @@ function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; -begin - if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then + explode, poison: boolean; + n: LongInt; +begin + if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeUtilityCrate', 'x, y [, explode [, poison]]', n) then begin + explode:= false; + poison:= false; + if (n >= 3) and (not lua_isnil(L, 3)) then + explode:= lua_toboolean(L, 3); + if (n = 4) and (not lua_isnil(L, 4)) then + poison:= lua_toboolean(L, 4); + gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), - UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + UtilityCrate, explode, poison); if gear <> nil then lua_pushnumber(L, gear^.uid) else lua_pushnil(L)