1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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.
This commit is contained in:
sfan5 2016-11-26 17:35:25 +01:00
parent 2fe3bf5a18
commit c38985825f
5 changed files with 25 additions and 13 deletions

View file

@ -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;