diff --git a/changelog.md b/changelog.md index c2b292a..c59c034 100644 --- a/changelog.md +++ b/changelog.md @@ -2,9 +2,12 @@ - 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 the ability to toggle respec confirmations. +- Added custom respec confirmation messages. - The red layer highlight will not appear before a layer is unlocked. - Added unlocking hotkeys. - Node symbols can use HTML. +- Added documentation for the respec button. # v2.π.1 - 4/7/21 - Fixed formatting for some larger numbers. diff --git a/docs/buyables.md b/docs/buyables.md index a648d64..8e64945 100644 --- a/docs/buyables.md +++ b/docs/buyables.md @@ -1,6 +1,6 @@ # 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`. @@ -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. - 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. \ No newline at end of file diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index e737931..18034a8 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -159,6 +159,7 @@ addLayer("c", { doReset(this.layer, true) // Force a reset }, respecText: "Respec Thingies", // Text on Respec button, optional + respecMessage: "Are you sure? Respeccing these doesn't accomplish much.", 11: { 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 @@ -422,7 +423,7 @@ addLayer("f", { clickables: { rows: 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...") player[this.layer].clickables[11] = "Start" }, diff --git a/js/utils.js b/js/utils.js index 28b9149..682d46a 100644 --- a/js/utils.js +++ b/js/utils.js @@ -3,7 +3,7 @@ function respecBuyables(layer) { if (!layers[layer].buyables) 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) updateBuyableTemp(layer) document.activeElement.blur()