mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-22 08:31:33 +00:00
54 lines
No EOL
2.3 KiB
Markdown
54 lines
No EOL
2.3 KiB
Markdown
# Buyables
|
|
|
|
Buyables are usually things that can be bought multiple times with scaling costs. If you set a respec function,
|
|
the player can reset the purchases to get their currency back.
|
|
|
|
However, if you're creative, you can use them for basically anything. "canAfford()" is effectively "canClick()" and "buy()" is effectively "onClick()".
|
|
|
|
The amount of a buyable owned is a Decimal, and can be accessed with buyablesOwned(layer, id).
|
|
You can use buyableEffect(layer, id) to get the current effects of a buyable.
|
|
|
|
Buyables should be formatted like this:
|
|
|
|
```js
|
|
buyables: {
|
|
rows: # of rows
|
|
cols: # of columns
|
|
respec() {}, **optional**, implement it to reset things and give back your currency.
|
|
Having this function makes a respec button appear
|
|
respecText: **optional**, text that appears on the respec button
|
|
11: {
|
|
desc:() => "Blah",
|
|
etc
|
|
}
|
|
etc
|
|
}
|
|
```
|
|
|
|
Features:
|
|
|
|
- title: **optional**, displayed at the top in a larger font
|
|
It can also be a function that returns updating text.
|
|
|
|
- cost(): cost for buying the next buyable. Can have an optional argument "x" to calculate the cost of the x+1th object,
|
|
but needs to use "current amount" as a default value for x. Can return an object if there are multiple currencies.
|
|
|
|
- effect(): **optional**, A function that calculates and returns the current values of bonuses
|
|
of this buyable. Can return a value or an object containing multiple values.
|
|
|
|
- display(): A function returning everything that should be displayed on the rebuyable after the title, likely
|
|
including the description, amount bought, cost, and current effect. Can use basic HTML.
|
|
|
|
- unl(): A function returning a bool to determine if the buyable is visible or not.
|
|
|
|
- canAfford(): A function returning a bool to determine if you can buy one of the buyables.
|
|
|
|
- buy(): A function that implements buying one of the buyable.
|
|
|
|
- buyMax(): **optional**, A function that implements buying as many of the buyable as possible.
|
|
|
|
- style: **Optional**, A CSS object, which affects this buyable.
|
|
|
|
- layer: **Assigned automagically**. It's the same value as the name of this layer, so you can do player[this.layer].points or similar
|
|
|
|
- id: **Assigned automagically**. It's the id for this buyable. |