1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-12-04 22:01:31 +00:00
The-Modding-Tree/docs/milestones.md

43 lines
2.4 KiB
Markdown
Raw Normal View History

2020-10-15 17:29:25 +00:00
# Milestones
2020-10-15 01:43:16 +00:00
Milestones are awarded to the player when they meet a certain goal, and give some benefit. Milestones should be formatted like this:
```js
2020-10-26 20:45:22 +00:00
milestones: {
0: {
2020-12-13 02:43:22 +00:00
requirementDescription: "123 waffles",
effectDescription: "blah",
2020-10-26 20:45:22 +00:00
done() { return player.w.points.gte(123) }
2020-10-01 05:41:25 +00:00
}
2020-10-26 20:45:22 +00:00
etc
}
```
2020-10-26 20:45:22 +00:00
You can use `hasMilestone(layer, id)` to determine if the player has a given milestone
Milestone features:
- requirementDescription: A string describing the requirement for unlocking this milestone. Suggestion: Use a "total". It can also be a function that returns updating text. Can use basic HTML.
- effectDescription: A string describing the reward for having the milestone. *You will have to implement the reward elsewhere.* It can also be a function that returns updating text. Can use basic HTML.
2020-10-15 01:43:16 +00:00
- done(): A function returning a boolean to determine if the milestone should be awarded.
2021-06-02 20:45:05 +00:00
- onComplete() - **optional**. this function will be called when the milestone is completed.
2020-10-26 20:45:22 +00:00
- toggles: **optional**. Creates toggle buttons that appear on the milestone when it is unlocked. The toggles can toggle a given boolean value in a layer. It is defined as an array of paired items, one pair per toggle. The first is the internal name of the layer the value being toggled is stored in, and the second is the internal name of the variable to toggle. (e.g. [["b", "auto"], ["g", "auto"])
2020-10-03 19:45:47 +00:00
2020-10-26 20:45:22 +00:00
**Tip:** Toggles are not de-set if the milestone becomes locked! In this case, you should also check if the player has the milestone.
2020-10-26 20:45:22 +00:00
- style: **optional**. Applies CSS to this milestone, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).
2020-10-07 20:41:45 +00:00
2020-10-26 20:45:22 +00:00
- unlocked(): **optional**. A function returning a boolean to determine if the milestone should be shown. If absent, it is always shown.
2020-10-07 20:41:45 +00:00
2021-06-10 04:54:36 +00:00
- tooltip: **optional**. Adds a tooltip to this milestone, appears when it is hovered over. Can use basic HTML. Default is no tooltip. If this returns an empty value, that also disables the tooltip.
2020-10-26 20:45:22 +00:00
- layer: **assigned automagically**. It's the same value as the name of this layer, so you can do `player[this.layer].points` or similar.
2020-10-03 19:45:47 +00:00
2020-10-26 20:45:22 +00:00
- id: **assigned automagically**. It's the "key" which the milestone was stored under, for convenient access. The milestone in the example's id is 0.
2020-12-07 05:40:30 +00:00
2021-06-02 20:45:05 +00:00
Disable milestone popups by adding `milestonePopups: false` to the layer.