1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 17:31:50 +00:00

Added custom respec messages + respec documentation

This commit is contained in:
Harley White 2021-04-29 18:03:51 -04:00
parent b9a858af56
commit 9fe4a17a38
4 changed files with 19 additions and 3 deletions

View file

@ -2,9 +2,12 @@
- Completely reworked tooltips. Shift-click a node to force its tooltip to stay displayed. (And hopefully finally fixed flickering!) - Completely reworked tooltips. Shift-click a node to force its tooltip to stay displayed. (And hopefully finally fixed flickering!)
- Added text-input and slider components. - Added text-input and slider components.
- Added the ability to toggle respec confirmations.
- Added custom respec confirmation messages.
- The red layer highlight will not appear before a layer is unlocked. - The red layer highlight will not appear before a layer is unlocked.
- Added unlocking hotkeys. - Added unlocking hotkeys.
- Node symbols can use HTML. - Node symbols can use HTML.
- Added documentation for the respec button.
# v2.π.1 - 4/7/21 # v2.π.1 - 4/7/21
- Fixed formatting for some larger numbers. - Fixed formatting for some larger numbers.

View file

@ -1,6 +1,6 @@
# Buyables # 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. Buyables are usually things that can be bought multiple times with scaling costs. They come with optional buttons that can be used for respeccing or selling buyables, among other things.
The amount of a buyable owned is a `Decimal`. The amount of a buyable owned is a `Decimal`.
@ -61,3 +61,15 @@ Including a `sellOne` or `sellAll` function will cause an additional button to a
- sellOne/sellAll(): **optional**. Called when the button is pressed. The standard use would be to decrease/reset the amount of the buyable, and possibly return some currency to the player. - sellOne/sellAll(): **optional**. Called when the button is pressed. The standard use would be to decrease/reset the amount of the buyable, and possibly return some currency to the player.
- canSellOne/canSellAll(): **optional**. booleans determining whether or not to show the buttons. If "canSellOne/All" is absent but "sellOne/All" is present, the appropriate button will always show. - canSellOne/canSellAll(): **optional**. booleans determining whether or not to show the buttons. If "canSellOne/All" is absent but "sellOne/All" is present, the appropriate button will always show.
To add a respec button, or something similar, add the respecBuyables function to the main buyables object (not individual buyables).
You can use these features along with it:
- respecBuyables(): **optional**. This is called when the button is pressed (after a toggleable confirmation message).
- respecText: **optional**. Text to display on the respec Button.
- showRespec(): **optional**. A function determining whether or not to show the button, if respecBuyables is defined. Defaults to true if absent.
- respecMessage: **optional**. A custom confirmation message on respec, in place of the default one.

View file

@ -159,6 +159,7 @@ addLayer("c", {
doReset(this.layer, true) // Force a reset doReset(this.layer, true) // Force a reset
}, },
respecText: "Respec Thingies", // Text on Respec button, optional respecText: "Respec Thingies", // Text on Respec button, optional
respecMessage: "Are you sure? Respeccing these doesn't accomplish much.",
11: { 11: {
title: "Exhancers", // Optional, displayed at the top in a larger font title: "Exhancers", // Optional, displayed at the top in a larger font
cost(x=player[this.layer].buyables[this.id]) { // cost for buying xth buyable, can be an object if there are multiple currencies cost(x=player[this.layer].buyables[this.id]) { // cost for buying xth buyable, can be an object if there are multiple currencies
@ -422,7 +423,7 @@ addLayer("f", {
clickables: { clickables: {
rows: 1, rows: 1,
cols: 1, cols: 1,
masterButtonPress() { // Optional, reset things and give back your currency. Having this function makes a respec button appear masterButtonPress() {
if (getClickableState(this.layer, 11) == "Borkened...") if (getClickableState(this.layer, 11) == "Borkened...")
player[this.layer].clickables[11] = "Start" player[this.layer].clickables[11] = "Start"
}, },

View file

@ -3,7 +3,7 @@
function respecBuyables(layer) { function respecBuyables(layer) {
if (!layers[layer].buyables) return if (!layers[layer].buyables) return
if (!layers[layer].buyables.respec) return if (!layers[layer].buyables.respec) return
if (!player[layer].noRespecConfirm && !confirm("Are you sure you want to respec? This will force you to do a \"" + (tmp[layer].name ? tmp[layer].name : layer) + "\" reset as well!")) return if (!player[layer].noRespecConfirm && !confirm(tmp[layer].buyables.respecMessage || "Are you sure you want to respec? This will force you to do a \"" + (tmp[layer].name ? tmp[layer].name : layer) + "\" reset as well!")) return
run(layers[layer].buyables.respec, layers[layer].buyables) run(layers[layer].buyables.respec, layers[layer].buyables)
updateBuyableTemp(layer) updateBuyableTemp(layer)
document.activeElement.blur() document.activeElement.blur()