mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Fix object reference pushing functions when called from coroutines
This commit is contained in:
@@ -40,7 +40,7 @@ bool ScriptApiItem::item_OnDrop(ItemStack &item,
|
||||
|
||||
// Call function
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(dropper);
|
||||
objectrefGetOrCreate(L, dropper);
|
||||
pushFloatPos(L, pos);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
@@ -66,7 +66,7 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item,
|
||||
|
||||
// Call function
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(placer);
|
||||
objectrefGetOrCreate(L, placer);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
@@ -92,7 +92,7 @@ bool ScriptApiItem::item_OnUse(ItemStack &item,
|
||||
|
||||
// Call function
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(user);
|
||||
objectrefGetOrCreate(L, user);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
@@ -115,7 +115,7 @@ bool ScriptApiItem::item_OnCraft(ItemStack &item, ServerActiveObject *user,
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "on_craft");
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(user);
|
||||
objectrefGetOrCreate(L, user);
|
||||
|
||||
// Push inventory list
|
||||
std::vector<ItemStack> items;
|
||||
@@ -146,7 +146,7 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "craft_predict");
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(user);
|
||||
objectrefGetOrCreate(L, user);
|
||||
|
||||
//Push inventory list
|
||||
std::vector<ItemStack> items;
|
||||
@@ -229,7 +229,7 @@ void ScriptApiItem::pushPointedThing(const PointedThing& pointed)
|
||||
{
|
||||
lua_pushstring(L, "object");
|
||||
lua_setfield(L, -2, "type");
|
||||
objectrefGet(pointed.object_id);
|
||||
objectrefGet(L, pointed.object_id);
|
||||
lua_setfield(L, -2, "ref");
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user