1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-27 18:41:57 +00:00
The-Modding-Tree/docs/achievements.md

55 lines
3 KiB
Markdown
Raw Normal View History

2020-10-15 17:29:25 +00:00
# Achievements
2020-10-15 01:43:16 +00:00
2021-05-11 01:24:24 +00:00
Achievements are awarded to the player when they meet a certain goal, and optionally give some benefit.
2020-10-15 01:43:16 +00:00
2020-10-26 20:45:22 +00:00
You can make global achievements by putting them in a side layer by making its row equal to "side" instead of a number.
2020-10-15 01:43:16 +00:00
Useful functions for dealing with achievements and implementing their effects:
2020-10-26 20:45:22 +00:00
- hasAchievement(layer, id): determine if the player has the Achievement.
- achievementEffect(layer, id): Returns the current effects of the achievement, if any.
2020-10-15 01:43:16 +00:00
Achievements should be formatted like this:
```js
2020-10-26 20:45:22 +00:00
achievements: {
11: {
name: "Blah",
more features
},
etc
}
2020-10-15 01:43:16 +00:00
```
2021-05-13 05:44:40 +00:00
Usually, each achievement should have an id where the first digit is the row and the second digit is the column.
2020-10-26 20:45:22 +00:00
2020-10-15 01:43:16 +00:00
Individual achievement can have these features:
2020-10-26 20:45:22 +00:00
- name: **optional**. displayed at the top of the achievement. The only visible text. 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 achievement should be awarded.
- tooltip: Default tooltip for the achievement, appears when it is hovered over. Should convey the goal and any reward for completing the achievement. It can also be a function that returns updating text. Can use basic HTML. Setting this to "" disables the tooltip.
2020-10-15 01:43:16 +00:00
2020-10-26 20:45:22 +00:00
- effect(): **optional**. A function that calculates and returns the current values of any bonuses from the achievement. Can return a value or an object containing multiple values.
2020-10-15 01:43:16 +00:00
2020-10-26 20:45:22 +00:00
- unlocked(): **optional**. A function returning a bool to determine if the achievement is visible or not. Default is unlocked.
2020-10-15 01:43:16 +00:00
2020-10-26 20:45:22 +00:00
- onComplete() - **optional**. this function will be called when the achievement is completed.
2020-10-15 01:43:16 +00:00
2020-12-09 06:36:27 +00:00
- image: **optional**, puts the image from the given URL (relative or absolute) in the achievement
2020-10-26 20:45:22 +00:00
- style: **optional**. Applies CSS to this achievement, 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-12-09 06:36:27 +00:00
- textStyle: **optional**. Applies CSS to the text, 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-15 01:43:16 +00:00
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-16 15:39:39 +00:00
2020-10-26 20:45:22 +00:00
- id: **assigned automagically**. It's the "key" which the achievement was stored under, for convenient access. The achievement in the example's id is 11.
2020-10-16 15:39:39 +00:00
2020-10-26 20:45:22 +00:00
- goalTooltip: **optional, deprecated**. Appears when the achievement is hovered over and locked, overrides the basic tooltip. This is to display the goal (or a hint). It can also be a function that returns updating text. Can use basic HTML.
2020-10-16 15:39:39 +00:00
2020-10-26 20:45:22 +00:00
- doneTooltip: **optional, deprecated**. Appears when the achievement is hovered over and completed, overrides the basic tooltip. This can display what the player achieved (the goal), and the rewards, if any. It can also be a function that returns updating text. Can use basic HTML.
2020-12-07 05:40:30 +00:00
2020-12-10 06:31:42 +00:00
Disable achievement popups by adding `achievementsPopups: false` to the layer.