# How to change the currency for a buyable purchase

**URL:** <https://forums.moddingtree.com/t/how-to-change-the-currency-for-a-buyable-purchase/1393>\
**Category:** Modding Developers\
**Created:** [February 16, 2024, 7:58pm UTC](https://forums.moddingtree.com/t/how-to-change-the-currency-for-a-buyable-purchase/1393 "2024-02-16T19:58:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daide](https://forums.moddingtree.com/letter_avatar_proxy/v4/letter/d/3e96dc/32.png) [@Daide](https://forums.moddingtree.com/u/Daide)\
**Post date:** [February 16, 2024, 7:58pm UTC](https://forums.moddingtree.com/t/how-to-change-the-currency-for-a-buyable-purchase/1393/1 "2024-02-16T19:58:31Z")

</div>

Please, help. I’m stuck when changing the currency. I check docs, but found nothing

---

<div class="post-metadata">

**Author:** ![Acyth3](https://forums.moddingtree.com/user_avatar/forums.moddingtree.com/acyth3/32/849_2.png) [@Acyth3](https://forums.moddingtree.com/u/Acyth3)\
**Post date:** [February 21, 2024, 12:22am UTC](https://forums.moddingtree.com/t/how-to-change-the-currency-for-a-buyable-purchase/1393/2 "2024-02-21T00:22:16Z")

</div>

Here’s an example used in an buyable (that I use for different currencies)

11: {  
title: “Buyable Example”,  
unlocked() { return true },  
cost(x) {  
let exp1 = new Decimal(1.2)  
let exp2 = new Decimal (1.1005)  
return new Decimal(2).mul(Decimal.pow(exp1, x)).mul(Decimal.pow(x , Decimal.pow(exp2 , x)))).floor()  
},  
display() {  
return “Cost: " + format(tmp[this.layer].buyables[this.id].cost) + " A-Points” + "  
Bought: " + getBuyableAmount(this.layer, this.id) + “  
Effect: Nothing” + format(buyableEffect(this.layer, this.id))  
},  
canAfford() {  
return player.A.points.gte(this.cost())  
},  
buy() {  
let cost = new Decimal (1)  
player.A.points = player.A.points.sub(this.cost().mul(cost))  
setBuyableAmount(this.layer, this.id, getBuyableAmount(this.layer, this.id).add(1))  
},  
effect(x) {  
let base1 = new Decimal(1.46)  
let base2 = x  
let expo = new Decimal(1.012)  
let eff = base1.pow(Decimal.pow(base2, expo)).times(buyableEffect(‘mE’, 14).pow(0.2))  
return eff  
},  
},

Not sure if it works since I wrote it in here instead of VSCode.

[Change Buy() & canAfford() to your conditions of currency :)] (Same with everything else in here)
