From f0e7da8a63d858f3b511872cf41cde0eaff6585d Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 1 Apr 2012 16:06:01 +0300 Subject: Implement dropped items as LuaEntities; leave the old ones as is for compatibility --- src/scriptapi.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/scriptapi.cpp') diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index f8fca00c7..a45c27de6 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -3042,7 +3042,21 @@ private: ItemStack item = read_item(L, 3); if(item.empty() || !item.isKnown(get_server(L)->idef())) return 0; - // Do it + // Use minetest.spawn_item to spawn a __builtin:item + lua_getglobal(L, "minetest"); + lua_getfield(L, -1, "spawn_item"); + if(lua_isnil(L, -1)) + return 0; + lua_pushvalue(L, 2); + lua_pushstring(L, item.getItemString().c_str()); + if(lua_pcall(L, 2, 1, 0)) + script_error(L, "error: %s", lua_tostring(L, -1)); + return 1; + /*lua_pushvalue(L, 1); + lua_pushstring(L, "__builtin:item"); + lua_pushstring(L, item.getItemString().c_str()); + return l_add_entity(L);*/ + /*// Do it ServerActiveObject *obj = createItemSAO(env, pos, item.getItemString()); int objectid = env->addActiveObject(obj); // If failed to add, return nothing (reads as nil) @@ -3050,7 +3064,7 @@ private: return 0; // Return ObjectRef objectref_get_or_create(L, obj); - return 1; + return 1;*/ } // EnvRef:add_rat(pos) -- cgit v1.2.3