diff --git a/changelog.md b/changelog.md
index d3d4e44..027d197 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
- Moved most of the code users will want to edit to mod.js.
- Added getStartPoints()
+- Added "sell one" and "sell all" buttons for buyables.
- Fixed issues with version number
### v2.0.5 - 10/16/20
diff --git a/docs/buyables.md b/docs/buyables.md
index d5b4bbf..2a611cb 100644
--- a/docs/buyables.md
+++ b/docs/buyables.md
@@ -17,6 +17,7 @@ Buyables should be formatted like this:
// Having this function makes a respec button appear
respecText:// **optional**, text that appears on the respec button
showRespecButton(){} //**optional**, a function determining whether or not to show the button. Defaults to true if absent.
+ sellOneText, sellAllText:// **optional**, text that appears on the "sell one" and "sell all" buttons respectively (if you are using them)
11: {
display() {return "Blah"},
etc
@@ -54,4 +55,15 @@ Features:
- layer: **Assigned automagically**. It's the same value as the name of this layer, so you can do player[this.layer].points or similar
- id: **Assigned automagically**. It's the "key" which the buyable was stored under, for convenient access.
- The buyable in the example's id is 11.
\ No newline at end of file
+ The buyable in the example's id is 11.
+
+Sell One/Sell All:
+
+Including a sellOne or sellAll function will cause an additional button to appear beneath the buyable.
+They are functionally identical, but "sell one" appears above "sell all". You can also use them for other things.
+
+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.
\ No newline at end of file
diff --git a/docs/custom-tab-layouts.md b/docs/custom-tab-layouts.md
index 58f9b5a..b13df94 100644
--- a/docs/custom-tab-layouts.md
+++ b/docs/custom-tab-layouts.md
@@ -48,11 +48,16 @@ These are the existing components, but you can create more in v.js:
- microtabs: Display a set of subtabs for an area. The argument is the name of the set of microtabs in the "microtabs" feature.
-- upgrade, milestone, chall, buyable, clickable, achievement: An individual upgrade, challenge, etc. The argument is the id.
- This can be used if you want to have upgrades split up across multiple subtabs, for example.
-
- bar: Display a bar. The argument is the id of the bar to display.
- toggle: A toggle button that toggles a bool value. The data is a pair that identifies what bool to toggle, [layer, id]
-- respec-button, master-button: The respec and master buttons for buyables and clickables, respectively.
\ No newline at end of file
+
+The rest of the components are sub-components. They can be used just like other components, but are typically part of another component.
+
+- upgrade, milestone, chall, buyable, clickable, achievement: An individual upgrade, challenge, etc. The argument is the id.
+ This can be used if you want to have upgrades split up across multiple subtabs, for example.
+
+- respec-button, master-button: The respec and master buttons for buyables and clickables, respectively.
+
+- sell-one, sell-all: The "sell one" and "sell all" for buyables, respectively. The argument is the id of the buyable.
\ No newline at end of file
diff --git a/js/layers.js b/js/layers.js
index 35a8b96..43c148c 100644
--- a/js/layers.js
+++ b/js/layers.js
@@ -176,7 +176,13 @@ addLayer("c", {
player[this.layer].spentOnBuyables = player[this.layer].spentOnBuyables.add(cost) // This is a built-in system that you can use for respeccing but it only works with a single Decimal value
},
buyMax() {}, // You'll have to handle this yourself if you want
- style: {'height':'222px'}
+ style: {'height':'222px'},
+ sellOne() {
+ let amount = getBuyableAmount(this.layer, this.id)
+ if (amount.lte(0)) return // Only sell one if there is at least one
+ setBuyableAmount(this.layer, this.id, amount.sub(1))
+ player[this.layer].points = player[this.layer].points.add(this.cost())
+ },
},
},
doReset(resettingLayer){ // Triggers when this layer is being reset, along with the layer doing the resetting. Not triggered by lower layers resetting, but is by layers on the same row.
diff --git a/js/temp.js b/js/temp.js
index 3cdc961..8bc1fac 100644
--- a/js/temp.js
+++ b/js/temp.js
@@ -3,7 +3,8 @@ var tmp = {}
// Tmp will not call these
var activeFunctions = [
"startData", "onPrestige", "doReset", "update", "automate",
- "buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "masterButtonPress"
+ "buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "masterButtonPress",
+ "sellOne", "sellAll",
]
var noCall = doNotCallTheseFunctionsEveryTick
diff --git a/js/v.js b/js/v.js
index 38ab290..a499fc7 100644
--- a/js/v.js
+++ b/js/v.js
@@ -202,7 +202,7 @@ function loadVue() {