mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix object reference pushing functions when called from coroutines
This commit is contained in:
parent
28438bba27
commit
741df993ff
10 changed files with 42 additions and 45 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue