mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-13 22:34:53 +02:00
introduce gold converting ring
This commit is contained in:
35
data/actions/scripts/misc/changegold.lua
Normal file
35
data/actions/scripts/misc/changegold.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local config = {
|
||||
[3031] = {changeTo = 3035},
|
||||
[3035] = {changeBack = 3031, changeTo = 3043},
|
||||
[3043] = {changeBack = 3035}
|
||||
}
|
||||
|
||||
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
|
||||
local ring = player:getSlotItem(CONST_SLOT_RING)
|
||||
if ring == nil or ring:getId() ~= 3007 then
|
||||
return false
|
||||
end
|
||||
|
||||
local ringCharges = ring:getAttribute(ITEM_ATTRIBUTE_CHARGES)
|
||||
local coin = config[item:getId()]
|
||||
if coin.changeTo and item.type == 100 then
|
||||
item:remove()
|
||||
player:addItem(coin.changeTo, 1)
|
||||
if ringCharges > 1 then
|
||||
ring:setAttribute(ITEM_ATTRIBUTE_CHARGES,(ringCharges-1))
|
||||
else
|
||||
ring:remove(1)
|
||||
end
|
||||
elseif coin.changeBack then
|
||||
item:remove(1)
|
||||
player:addItem(coin.changeBack, 100)
|
||||
if ringCharges > 1 then
|
||||
ring:setAttribute(ITEM_ATTRIBUTE_CHARGES,(ringCharges-1))
|
||||
else
|
||||
ring:remove(1)
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
Reference in New Issue
Block a user