From c798b3c82c422b4ef4fec4a507aa7693c439f0be Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 22 Feb 2024 15:03:59 -0300 Subject: [PATCH] refactor: centralize storage store coins/wheel scrolls to the core (#2284) Moved scripts to core and added warning log to the tibia coins item, as players should not have access to this item. --- .../actions => data/scripts/actions/items}/store_coins.lua | 7 +++++-- .../scripts/actions/items}/wheel_scrolls.lua | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) rename {data-otservbr-global/scripts/actions => data/scripts/actions/items}/store_coins.lua (78%) rename {data-otservbr-global/scripts/actions => data/scripts/actions/items}/wheel_scrolls.lua (99%) diff --git a/data-otservbr-global/scripts/actions/store_coins.lua b/data/scripts/actions/items/store_coins.lua similarity index 78% rename from data-otservbr-global/scripts/actions/store_coins.lua rename to data/scripts/actions/items/store_coins.lua index b52611dd30c..6e4f0cf45c1 100644 --- a/data-otservbr-global/scripts/actions/store_coins.lua +++ b/data/scripts/actions/items/store_coins.lua @@ -1,11 +1,14 @@ local storeCoin = Action() function storeCoin.onUse(player, item, fromPosition, target, toPosition, isHotkey) - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) local count = item:getCount() - item:remove() player:addTransferableCoins(count) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have added " .. count .. " tibia coins to your balance. Your total is now " .. player:getTransferableCoins() .. ".") + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) + item:remove() + + logger.warn("[StoreCoinScript - ITEM_STORE_COIN] The player {} used the item to store Tibia Coins.", player:getName()) + return true end storeCoin:id(ITEM_STORE_COIN) diff --git a/data-otservbr-global/scripts/actions/wheel_scrolls.lua b/data/scripts/actions/items/wheel_scrolls.lua similarity index 99% rename from data-otservbr-global/scripts/actions/wheel_scrolls.lua rename to data/scripts/actions/items/wheel_scrolls.lua index 76c87eeb8e1..b42339a706e 100644 --- a/data-otservbr-global/scripts/actions/wheel_scrolls.lua +++ b/data/scripts/actions/items/wheel_scrolls.lua @@ -23,7 +23,6 @@ function scroll.onUse(player, item, fromPosition, target, toPosition, isHotkey) player:setStorageValueByName(scrollData.storageName, 1) player:sendTextMessage(MESSAGE_LOOK, "You have gained " .. scrollData.points .. " promotion points for the Wheel of Destiny by deciphering the " .. scrollData.name .. ".") item:remove(1) - return true end