diff --git a/changelog.md b/changelog.md index b317a0a..c2b292a 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ - 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. - The red layer highlight will not appear before a layer is unlocked. +- Added unlocking hotkeys. - Node symbols can use HTML. # v2.π.1 - 4/7/21 diff --git a/docs/layer-features.md b/docs/layer-features.md index 2e027ea..a1ac761 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -46,7 +46,8 @@ You can make almost any value dynamic by using a function in its place, includin { key: "p", // What the hotkey button is. Use uppercase if it's combined with shift, or "ctrl+x" for holding down ctrl. description: "p: reset your points for prestige points", // The description of the hotkey that is displayed in the game's How To Play tab - onPress() { if (player.p.unlocked) doReset("p") } + onPress() { if (player.p.unlocked) doReset("p") }, + unlocked() {return hasMilestone('p', 3)} // Determines if you can use the hotkey, optional } ] ``` diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index 36a2140..e737931 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -212,8 +212,8 @@ addLayer("c", { }, // Useful for if you gain secondary resources or have other interesting things happen to this layer when you reset it. You gain the currency after this function ends. hotkeys: [ - {key: "c", description: "C: reset for lollipops or whatever", onPress(){if (canReset(this.layer)) doReset(this.layer)}, unlocked() {return player.points.gte(10)}}, - {key: "ctrl+c", description: "Ctrl+c: respec things", onPress(){if (player[this.layer].unlocked) respecBuyables(this.layer)}}, + {key: "c", description: "C: reset for lollipops or whatever", onPress(){if (canReset(this.layer)) doReset(this.layer)}}, + {key: "ctrl+c", description: "Ctrl+c: respec things", onPress(){respecBuyables(this.layer)}, unlocked() {return hasUpgrade('c', '22')}} , ], increaseUnlockOrder: [], // Array of layer names to have their order increased when this one is first unlocked diff --git a/js/utils.js b/js/utils.js index c594921..56e7227 100644 --- a/js/utils.js +++ b/js/utils.js @@ -329,8 +329,10 @@ document.onkeydown = function (e) { if (onFocused) return if (ctrlDown && hotkeys[key]) e.preventDefault() if (hotkeys[key]) { - if (player[hotkeys[key].layer].unlocked) - hotkeys[key].onPress() + let k = hotkeys[key] + console.log(tmp[k.layer].hotkeys) + if (player[k.layer].unlocked && tmp[k.layer].hotkeys[k.id].unlocked) + k.onPress() } }