From 2ac20982e0772b94b21d95b53519bd2164632d98 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 24 Jul 2012 20:57:17 +0300 Subject: Detached inventories --- src/scriptapi.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/scriptapi.cpp') diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 12d2a8247..9959ddd74 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -4567,6 +4567,9 @@ static int l_get_inventory(lua_State *L) lua_getfield(L, 1, "pos"); v3s16 pos = check_v3s16(L, -1); loc.setNodeMeta(pos); + } else if(type == "detached"){ + std::string name = checkstringfield(L, 1, "name"); + loc.setDetached(name); } if(get_server(L)->getInventory(loc) != NULL) @@ -4576,6 +4579,20 @@ static int l_get_inventory(lua_State *L) return 1; } +// create_detached_inventory(name) +static int l_create_detached_inventory(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + if(get_server(L)->createDetachedInventory(name) != NULL){ + InventoryLocation loc; + loc.setDetached(name); + InvRef::create(L, loc); + }else{ + lua_pushnil(L); + } + return 1; +} + // get_dig_params(groups, tool_capabilities[, time_from_last_punch]) static int l_get_dig_params(lua_State *L) { @@ -4849,6 +4866,7 @@ static const struct luaL_Reg minetest_f [] = { {"chat_send_player", l_chat_send_player}, {"get_player_privs", l_get_player_privs}, {"get_inventory", l_get_inventory}, + {"create_detached_inventory", l_create_detached_inventory}, {"get_dig_params", l_get_dig_params}, {"get_hit_params", l_get_hit_params}, {"get_current_modname", l_get_current_modname}, -- cgit v1.2.3