mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Implement dropped items as LuaEntities; leave the old ones as is for compatibility
This commit is contained in:
parent
5bd32eca0f
commit
f0e7da8a63
6 changed files with 130 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue