diff options
author | sfan5 <sfan5@live.de> | 2016-11-26 17:35:25 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2016-11-28 13:41:19 +0100 |
commit | c38985825f299999135cc01aaf0052ec9138135a (patch) | |
tree | c54db1b2f7e8a27dd5c1d693c6e0ee92386271b9 /src/script/lua_api | |
parent | 2fe3bf5a18eb9aa9f38654b3c0a0729c42408cd6 (diff) | |
download | minetest-c38985825f299999135cc01aaf0052ec9138135a.tar.gz minetest-c38985825f299999135cc01aaf0052ec9138135a.tar.bz2 minetest-c38985825f299999135cc01aaf0052ec9138135a.zip |
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.
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_inventory.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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; |