Pedrook
Advanced OT User
- Joined
- May 24, 2009
- Messages
- 442
- Solutions
- 3
- Reaction score
- 183
- Location
- Brazil
- GitHub
- pedrogiampietro
Hello, I would like help to make some modifications to the change gold, every time you exchange a gold, regardless of the backpack it is it goes to the main backpack, I would like to change in the blue backpack 100 gold coin and it would transform 1 platinum coin into blue backpack, were not for the main backpack.
is this in the conversion or source script itself?
is this in the conversion or source script itself?
Lua:
local config = {
[ITEM_GOLD_COIN] = {changeTo = ITEM_PLATINUM_COIN},
[ITEM_PLATINUM_COIN] = {changeBack = ITEM_GOLD_COIN, changeTo = ITEM_CRYSTAL_COIN},
[ITEM_CRYSTAL_COIN] = {changeBack = ITEM_PLATINUM_COIN}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local coin = config[target.itemid]
if not coin then
return false
end
local charges = item:getCharges()
if coin.changeTo and target.type == 100 then
target:remove()
player:addItem(coin.changeTo, 1)
item:transform(item:getId(), charges -1)
elseif coin.changeBack then
target:transform(target.itemid, target.type - 1)
player:addItem(coin.changeBack, 100)
item:transform(item:getId(), charges -1)
else
return false
end
if charges == 0 then
item:remove()
end
return true
end