Page 1 of 1
How to mod a coin exchange
Posted: Fri Oct 10, 2014 6:34 pm
by KnotuAgain
I would like to create a mod that would exchange 10 copper coins for 1 gold coin. However it counts one stack of coins as one. Short of having to put ten coins in one at a time, is here anything else I can do?
Re: How to mod a coin exchange
Posted: Fri Oct 10, 2014 11:28 pm
by cromcrom
Hi there. I created this system for The Lost Continent. I hope it helps.
Code: Select all
--gold_coin
defineObject{
name = "gold_coin",
class = "Item",
uiName = "Gold coin",
model = "mod_assets/models/goldcoin.fbx",
gfxAtlas = "mod_assets/textures/TLC_items.tga",
gfxIndex = 8,
stackable = true,
weight = 0,
}
--copper_coin
defineObject{
name = "copper_coin",
class = "Item",
uiName = "Copper coin",
model = "mod_assets/models/coppercoin.fbx",
gfxAtlas = "mod_assets/textures/TLC_items.tga",
gfxIndex = 20,
stackable = true,
weight = 0,
description = "Use the copper coins to change ten of them into a silver coin.",
onUseItem = function(self,champion)
local stackSize = self:getStackSize()
if stackSize >= 11 then
spawn("silver_coin",party.level,party.x,party.y,party.facing)
local newStackSize = stackSize - 10
self:setStackSize(newStackSize)
end
end,
}
--silver_coin
defineObject{
name = "silver_coin",
class = "Item",
uiName = "Silver coin",
model = "mod_assets/models/silvercoin.fbx",
gfxAtlas = "mod_assets/textures/TLC_items.tga",
gfxIndex = 9,
stackable = true,
weight = 0,
description = "Use the silver coins to change ten of them into a gold coin.",
onUseItem = function(self,champion)
local stackSize = self:getStackSize()
if stackSize >= 11 then
spawn("gold_coin",party.level,party.x,party.y,party.facing)
local newStackSize = stackSize - 10
self:setStackSize(newStackSize)
end
end,
}
Re: How to mod a coin exchange
Posted: Mon Oct 13, 2014 3:49 am
by KnotuAgain
Thank you, I will try it.
Re: How to mod a coin exchange
Posted: Mon Oct 13, 2014 7:28 am
by cromcrom
YW. I created copper, silver and gold coins, and "using" them piles would make some 1/10 exchange. This is what these scripts does.