From eef62c82a2e58700fc1216b0b8c03e421bc77995 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 30 Jun 2018 17:11:38 +0200 Subject: Modernize lua read (part 2 & 3): C++ templating assurance (#7410) * Modernize lua read (part 2 & 3): C++ templating assurance Implement the boolean reader Implement the string reader Also remove unused & unimplemented script_error_handler Add a reader with default value --- src/script/lua_api/l_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/script/lua_api/l_inventory.cpp') diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index f3097582e..04fa3a196 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -336,7 +336,7 @@ int InvRef::l_contains_item(lua_State *L) InventoryList *list = getlist(L, ref, listname); bool match_meta = false; if (lua_isboolean(L, 4)) - match_meta = lua_toboolean(L, 4); + match_meta = readParam(L, 4); if (list) { lua_pushboolean(L, list->containsItem(item, match_meta)); } else { @@ -525,7 +525,7 @@ int ModApiInventory::l_create_detached_inventory_raw(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char *name = luaL_checkstring(L, 1); - const char *player = lua_isstring(L, 2) ? lua_tostring(L, 2) : ""; + std::string player = readParam(L, 2, ""); if (getServer(L)->createDetachedInventory(name, player) != NULL) { InventoryLocation loc; loc.setDetached(name); -- cgit v1.2.3