diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-04-01 16:06:01 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-04-01 16:06:01 +0300 |
commit | f0e7da8a63d858f3b511872cf41cde0eaff6585d (patch) | |
tree | 5586e6807b2fc442db9ee99191caf38b7b77d207 /src | |
parent | 5bd32eca0f4c8afa8d933f7d7d1946cabaa8dc43 (diff) | |
download | minetest-f0e7da8a63d858f3b511872cf41cde0eaff6585d.tar.gz minetest-f0e7da8a63d858f3b511872cf41cde0eaff6585d.tar.bz2 minetest-f0e7da8a63d858f3b511872cf41cde0eaff6585d.zip |
Implement dropped items as LuaEntities; leave the old ones as is for compatibility
Diffstat (limited to 'src')
-rw-r--r-- | src/content_cao.cpp | 5 | ||||
-rw-r--r-- | src/scriptapi.cpp | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 2a9c8a91a..1241e0002 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1068,6 +1068,11 @@ public: bool do_interpolate = readU8(is); bool is_end_position = readU8(is); float update_interval = readF1000(is); + + // Place us a bit higher if we're physical, to not sink into + // the ground due to sucky collision detection... + if(m_prop.physical) + m_position += v3f(0,0.002,0); if(do_interpolate){ if(!m_prop.physical) 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) |