From c38985825f299999135cc01aaf0052ec9138135a Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 26 Nov 2016 17:35:25 +0100 Subject: Allow restricting detached inventories to one player This combats the problem of sending the hundreds of "creative" / "armor" or whatever detached invs that exist on popular servers to each and every player on join or on change of said invs. --- src/script/lua_api/l_inventory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index 110e68d23..38eade609 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -520,16 +520,17 @@ int ModApiInventory::l_get_inventory(lua_State *L) } } -// create_detached_inventory_raw(name) +// create_detached_inventory_raw(name, [player_name]) int ModApiInventory::l_create_detached_inventory_raw(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char *name = luaL_checkstring(L, 1); - if(getServer(L)->createDetachedInventory(name) != NULL){ + const char *player = lua_isstring(L, 2) ? lua_tostring(L, 2) : ""; + if (getServer(L)->createDetachedInventory(name, player) != NULL) { InventoryLocation loc; loc.setDetached(name); InvRef::create(L, loc); - }else{ + } else { lua_pushnil(L); } return 1; -- cgit v1.2.3