diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/serverpackethandler.cpp | 11 | ||||
-rw-r--r-- | src/script/cpp_api/s_item.cpp | 5 | ||||
-rw-r--r-- | src/script/cpp_api/s_item.h | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index d8fbeebd5..7a42ce5ef 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -1316,6 +1316,13 @@ void Server::handleCommand_Interact(NetworkPacket *pkt) << pointed_object->getDescription() << std::endl; // Do stuff + if (m_script->item_OnSecondaryUse( + selected_item, playersao, pointed)) { + if (playersao->setWieldedItem(selected_item)) { + SendInventory(playersao, true); + } + } + pointed_object->rightClick(playersao); } else if (m_script->item_OnPlace( selected_item, playersao, pointed)) { @@ -1376,8 +1383,10 @@ void Server::handleCommand_Interact(NetworkPacket *pkt) actionstream << player->getName() << " activates " << selected_item.name << std::endl; + pointed.type = POINTEDTHING_NOTHING; // can only ever be NOTHING + if (m_script->item_OnSecondaryUse( - selected_item, playersao)) { + selected_item, playersao, pointed)) { if (playersao->setWieldedItem(selected_item)) { SendInventory(playersao, true); } diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp index cbdfcf1b1..24955cefc 100644 --- a/src/script/cpp_api/s_item.cpp +++ b/src/script/cpp_api/s_item.cpp @@ -115,7 +115,8 @@ bool ScriptApiItem::item_OnUse(ItemStack &item, return true; } -bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item, ServerActiveObject *user) +bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item, + ServerActiveObject *user, const PointedThing &pointed) { SCRIPTAPI_PRECHECKHEADER @@ -126,8 +127,6 @@ bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item, ServerActiveObject *use LuaItemStack::create(L, item); objectrefGetOrCreate(L, user); - PointedThing pointed; - pointed.type = POINTEDTHING_NOTHING; pushPointedThing(pointed); PCALL_RES(lua_pcall(L, 3, 1, error_handler)); if (!lua_isnil(L, -1)) { diff --git a/src/script/cpp_api/s_item.h b/src/script/cpp_api/s_item.h index 6c7f286a9..ad229f73e 100644 --- a/src/script/cpp_api/s_item.h +++ b/src/script/cpp_api/s_item.h @@ -42,7 +42,7 @@ public: bool item_OnUse(ItemStack &item, ServerActiveObject *user, const PointedThing &pointed); bool item_OnSecondaryUse(ItemStack &item, - ServerActiveObject *user); + ServerActiveObject *user, const PointedThing &pointed); bool item_OnCraft(ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv); bool item_CraftPredict(ItemStack &item, ServerActiveObject *user, |