From 18df2fd91087292914a726f29220aa92411181ec Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 15 Nov 2019 22:23:34 -0500 Subject: [PATCH] Make the attacker argument to wesnoth.units.resistance optional --- src/scripting/game_lua_kernel.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 7d316003392..ed6e49073dd 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -2421,11 +2421,16 @@ static int intf_unit_resistance(lua_State *L) { const unit& u = luaW_checkunit(L, 1); char const *m = luaL_checkstring(L, 2); - bool a = luaW_toboolean(L, 3); - + bool a = false; map_location loc = u.get_location(); - if (!lua_isnoneornil(L, 4)) { - loc = luaW_checklocation(L, 4); + + if(lua_isboolean(L, 3) { + a = luaW_toboolean(L, 3); + if(!lua_isnoneornil(L, 4)) { + loc = luaW_checklocation(L, 4); + } + } else if(!lua_isnoneornil(L, 3)) { + loc = luaW_checklocation(L, 3); } lua_pushinteger(L, u.resistance_against(m, a, loc));