1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-21 16:13:55 +00:00

Changed fullLayerReset to resetLayerData with ways to keep things

This commit is contained in:
Acamaeda 2020-10-13 18:56:17 -04:00
parent 95e1fc2ff0
commit 99d269b2d0
7 changed files with 41 additions and 25 deletions

View file

@ -1,8 +1,8 @@
#The Modding Tree changelog:
##v2.0
Added Progress bars, which are highly customizable and can be horizontal or vertical.
Added clickables, a more generalized variant of buyables!
Added progress bars, which are highly customizable and can be horizontal or vertical!
Added clickables, a more generalized variant of buyables.
Support for multiple completions of challenges.
Added getter/setter functions for buyable amount and such
Moved modInfo to game.js, added a spot for a Discord link, changelog link, and a separate mod version from the TMT version

View file

@ -2,10 +2,12 @@
The main way to add content is through creating layers. You can either add a layer directly in the layers object in layersSupportjs,
or declare it in another file and then do "`addLayer(layername, layerdata)`"
(good for breaking things up into smaller files). The existing layers are just examples and can be freely deleted.
You can use those as references and a base for your own layers.
You can also use them as references and a base for your own layers.
**You will also need to add layer nodes to the tree in the HTML, look for where it says "Modify the tree in the table below!"** While you're there, you can also edit the modInfo at the top to change the name for your mod and some other settings. A unique modId will prevent your mod's saves from conflicting with other mods.
The first thing you need to do is to edit the modInfo at the top of game.js to set your modID (a string). A
unique modId will prevent your mod's saves from conflicting with other mods.
Most of the time, you won't need to dive deep into the code to create things, but you still can if you really want to.
@ -15,6 +17,10 @@ The Modding Tree uses break_eternity.js to store large values. This means that m
and must be treated differently. For example, you have to use `new Decimal(x)` to create a Decimal value instead of a
plain number, and perform operations on them by calling functions. e.g, instead of `x = x + y`, use `x = x.add(y)`.
Almost all values can be either a constant value, or a dynamic value. Dynamic values are defined by putting a function
that returns what the value should be at any given time.
All display text can be basic HTML instead (But you can't use most Vue features there).
## Table of Contents:

View file

@ -25,6 +25,8 @@ These are the existing components, but you can create more in v.js:
- display-text: Displays some text (can use basic HTML). The argument is the text to display. It can also be a function that returns updating text.
- raw-html: Displays some basic HTML, can also be a function.
- blank: Adds empty space. The default dimensions are 8px x 17px. The argument changes the dimensions.
If it's a single value (e.g. "20px"), that determines the height.
If you have a pair of arguments, the first is width and the second is height.

View file

@ -145,9 +145,14 @@ Key:
# Other features
- doReset(resettingLayer): **optional**, is triggered when a layer on a row greater than or equal to this one does a reset.
If you use it, you can choose what to keep via milestones and such.
Without it, the default is to reset everything on the row, but only
if it was triggered by a layer in a higher row.
The default behavior is to reset everything on the row, but only if it was triggered by a layer in a higher row.
If you want to keep things, determine what to keep based on the resettingLayer, milestones, and such, then call
resetLayerData(layer, keep), where layer is this layer, and keep is an array of the names of things to keep.
It can include things like "points", "best", "total" (for this layer's prestige currency), "upgrades",
any unique variables like "generatorPower", etc.
If you want to only keep specific upgrades or something like that, save them in a separate variable, then
call resetLayerData, and then set player[layer].upgrades to the saved upgrades.
- update(diff): **optional**, this function is called every game tick. Use it for any passive resource production or
time-based things. diff is the time since the last tick.

View file

@ -14,11 +14,12 @@ let modInfo = {
offlineLimit: 1 // In hours
}
// Set your version in num and name, but leave the tmt values so people know what version it is
let VERSION = {
num: "1.3.5 maybe",
name: "Tabception... ception!",
tmtNum: "1.3.5 maybe",
tmtName: "Tabception... ception!"
num: "2.0",
name: "Finally making some progress!",
tmtNum: "2.0",
tmtName: "Finally making some progress!"
}
// Determines if it should show points/sec
@ -120,26 +121,28 @@ function rowReset(row, layer) {
layers[lr].doReset(layer)
}
else
if(layers[layer].row > layers[lr].row) fullLayerReset(lr)
if(layers[layer].row > layers[lr].row) layerDataReset(lr)
}
}
function fullLayerReset(layer) {
function layerDataReset(layer, keep = []) {
let storedData = {}
for (thing in keep) {
if (player[layer][keep[thing]] !== undefined)
storedData[keep[thing]] = player[layer][keep[thing]]
}
console.log(storedData)
player[layer] = layers[layer].startData();
player[layer].upgrades = []
player[layer].milestones = []
player[layer].challenges = []
if (layers[layer].tabFormat && !Array.isArray(layers[layer].tabFormat)) {
if (player.subtabs[layer] == undefined) player.subtabs[layer] = {}
if (player.subtabs[layer].mainTabs == undefined) player.subtabs[layer].mainTabs = Object.keys(layers[layer].tabFormat)[0]
}
if (layers[layer].microtabs) {
if (player.subtabs[layer] == undefined) player.subtabs[layer] = {}
for (item in layers[layer].microtabs)
if (player.subtabs[layer][item] == undefined) player.subtabs[layer][item] = Object.keys(layers[layer].microtabs[item])[0]
}
resetBuyables(layer)
for (thing in storedData) {
player[layer][thing] =storedData[thing]
}
}
function resetBuyables(layer){

View file

@ -175,7 +175,7 @@ addLayer("c", {
},
},
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.
if(layers[resettingLayer].row > this.row) fullLayerReset(this.layer) // This is actually the default behavior
if(layers[resettingLayer].row > this.row) layerDataReset(this.layer, ["upgrades", "challenges"]) // This is actually the default behavior
},
layerShown() {return true}, // Condition for when layer appears on the tree
automate() {

View file

@ -587,7 +587,7 @@ function focused(x) {
function prestigeButtonText(layer)
{
if(tmp[layer].type == "normal")
return `${ player[layer].points.lt(1e3) ? (tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for ") : ""}+<b>${formatWhole(tmp[layer].resetGain)}</b> ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `<br><br>Next at ${ (tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))}` : ""} ${ tmp[layer].baseResource }`
return `${ player[layer].points.lt(1e3) ? (tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for ") : ""}+<b>${formatWhole(tmp[layer].resetGain)}</b> ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `<br><br>Next at ${ (tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))} ${ tmp[layer].baseResource }` : ""}`
else if(tmp[layer].type== "static")
return `${tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for "}+<b>${formatWhole(tmp[layer].resetGain)}</b> ${tmp[layer].resource}<br><br>${player[layer].points.lt(20) ? (tmp[layer].baseAmount.gte(tmp[layer].nextAt)&&(tmp[layer].canBuyMax !== undefined) && tmp[layer].canBuyMax?"Next":"Req") : ""}: ${formatWhole(tmp[layer].baseAmount)} / ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAtDisp) : format(tmp[layer].nextAtDisp))} ${ tmp[layer].baseResource }
`