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

Simplified some things, and began work on new documentation

This commit is contained in:
Acamaeda 2020-09-30 22:55:38 -04:00
parent 2a78eb10a6
commit dcd175a6d4
8 changed files with 320 additions and 170 deletions

164
README.md
View file

@ -1,165 +1,5 @@
# The-Modding-Tree
How to add layers:
You can either add a layer directly into the layers object in layers.js, or declare it separately and then do "addLayer(layername, layerdata)" (good for breaking things up into smaller files)
You still need to add nodes to the tree in the HTML, add hotkeys, and do any non-standard displaying in the HTML. (You can use <div v-if="layer=='x'">Blah blah</div> to add sections to specific layers)
A modified version of The Prestige Tree that is much easier to mod. It still requires programming knowledge, but it's mostly pretty easy things and copy/pasting.
Layer features! In no particular order
-----Layer-defining features-----
startData() - Returns an object containing the default values for any saved data in this layer, including resources, toggles, upgrades, and more.
Required:
unl: a bool determining if it is unlocked or not
points: a Decimal, the main currency for the layer
Useful:
total: A decimal, tracks total amount of main currency
best: A decimal, tracks highest amount of main currency
order: used to keep track of relevant layers unlocked before this one.
upgrades, milestones, challs: Empty arrays. Needed if you are using the corresponding feature in this layer
color: A color associated with this layer, used in many places. (A string in hex format with a #)
row: The row of the layer
resource: Name of the main currency you gain by resetting on this layer.
effect() - Optional, returns the current strength of any effects derived from the layer's main currency
effectDescription() - Optional, returns a description of the effect this layer has
tabFormat: Optional. If you use this, you can make a custom layout for your tab, using any components defined in vue.js.
-----Prestige formula features-----
baseResource: The resource that determines how much of the main currency you gain on reset.
baseAmount() - How you get the current value of baseResource (e.g. baseAmount() {player.points})
requires() - A function that determines how much base resource you need to reset as a Decimal value. It can return a constant value, or change based on your order.
type: can be "normal" or "static". "normal" means the amount of currency you gain is independent of its current amount (like Prestige). "static" means that the cost grows depending on how much you already have (like Boosters). They both use different formulas. normal = x^exponent, static is base^(x^exponent)
exponent: Prestige currency exponent
base: Prestige currency base, only needed for "static" layers
resCeil: Bool, true if the resource needs to be rounded up
canBuyMax() - Only needed for static layers, used to determine if buying max is permitted.
gainMult(), gainExp() - Used to determine the multiplier and exponent on resource gain from upgrades and boosts and such. Plug all of them in here.
onPrestige(gain) - Optional, Triggers when this layer prestiges, just before you gain the currency. Can be used to have secondary resource gain on prestige, or to recalculate things or whatnot.
-----Other features-----
doReset(resettingLayer) - Optional, is triggered when a layer on a row greater than or equal to this one. 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 higher layer.
convertToDecimal() - Only needed if you have non-standard Decimal values in startData, to these values from strings to Decimals after loading.
layerShown() - Returns a bool determining if this layer's node should be visible on the tree.
update(diff) - Optional, part of the main loop, use it for any passive resource production or time-based things. diff is the time since the last update. Suggestion: use addPoints(layer, gain) when generating points to automatically update the best and total amounts.
automate() - Optional, use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate.
updateTemp() - Optional, use it to update anything in the "temp" object.
resetsNothing() - Optional, returns true if this layer shouldn't trigger any resets.
incr_order: Optional, an array of layer names, their order will increase by 1 when this one is first unlocked. Can be empty.
branches: Optional, an array of pairs consisting of a layer name and a number from 1 to 3. When this layer is visible, for each pair, there will be a branch from this layer to the other layer with a color determined by the number.
-----Upgrades-----
Upgrades are stored in the following format:
upgrades: {
rows: # of rows
cols: # of columns
11: {
[insert upgrade info here]
}
etc
}
Each upgrade should have an id where the first digit is the row and the second digit is the column. Individual upgrades can have these features:
desc: A description of the upgrade's effect
effect() - Optional, calculate and return the values of this upgrade's effects or effects.
effectDisp() - Optional, returns a display of the current effects of the upgrade with formatting. Default behavior is to just display the number appropriately formatted.
cost: A Decimal for the cost of the upgrade.
currencyDisplayName: Optional, if using a currency other than the main one for this layer, the name to display for that currency
currencyInternalName: The internal name for that currency
currencyLayer: The internal name of the layer for that currency. If it's not in a layer (like Points), omit.
unl() - Return a bool to determine if the upgrade is unlocked or not.
onPurchase() - Optional, this function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".
-----Milestones-----
Milestones should be formatted like this:
milestones: {
0: {
[insert milestone info here]
}
etc
}
Milestone features:
requirementDesc: A string describing the requirement
effectDesc: A string describing the reward for having the milestone
done() - A function to determine if the milestone has been fulfilled.
toggles: Creates toggle buttons on the milestone when it is unlocked. An array of paired items, one pair per toggle. The first is the internal name of the layer the value being toggled is stored in, and the second is the internal name of the variable to toggle. (e.g. [["b", "auto"], ["g", "auto"])
-----Challenges-----
Challenges are stored in the following format:
challs: {
rows: # of rows
cols: # of columns
11: {
[insert challenge info here]
}
etc
}
Each challenge should have an id where the first digit is the row and the second digit is the column. Individual upgrades can have these features:
name: Name of the challenge
desc: A description of what makes the challenge a challenge
reward: A description of the reward's effect
effect() - Optional, calculate and return the values of this upgrade's effects or effects.
effectDisp(x) - Optional, returns a display of the current effects of the upgrade with formatting. Default behavior is to just display the number appropriately formatted.
goal: A Decimal for the goal of the challenge's value.
currencyDisplayName: Optional, if using a goal currency other than basic Points, the name to display for that currency
currencyInternalName: The internal name for that currency
currencyLayer: The internal name of the layer for that currency. If it's not in a layer, omit.
unl() - Return a bool to determine if the challenge is unlocked or not.
onComplete() - Optional, this function will be called when the challenge is newly completed.
countsAs: An array of ids of other challenges in this layer that being in this challenge "counts as" being in.
You can look in the [documentation](docs/general-info.md) for more information on how it all works, or look at the code in layers.js and sampleLayers.js to see what it all looks like.

View file

@ -0,0 +1,34 @@
#Basic layer breakdown
This is a very minimal layer with minimal features. Most things will require additional features:
```
p: {
startData() { return { // startData is a function that returns default data for a layer.
unl: false, // You can add more variables here to add them to your layer.
points: new Decimal(0), // "points" is the internal name for the main resource you get on prestige
}},
color: "#FE0102", // The color for this layer, which affects many elements
resource: "prestige points", // The name of this layer's main prestige resource
row: 0, // The row this layer is on (0 is the first row)
baseResource: "points", // The name of the resource your prestige gain is based on
baseAmount() {return player.points}, // A function to return the current value of that resource
requires() {return new Decimal(200)}, // A function returning the amount of the base needed to gain 1 of the prestige currency.
// Also the amount required to unlock the layer.
type: "normal", // Determines the formula used for calculating prestige currency.
exponent: 0.5, // "normal" prestige gain is (currency^exponent)
gainMult() { // Returns your multiplier to your gain of the prestige resource
return new Decimal(1) // Factor in any bonuses multiplying gain here
},
gainExp() { // Returns your exponent to your gain of the prestige resource
return new Decimal(1)
},
layerShown() {return true}, // Returns a bool for if this layer's node should be visible in the tree.
},
```

181
docs/general-info.md Normal file
View file

@ -0,0 +1,181 @@
# The-Modding-Tree
The main way to add content is through creating layers. You can either add a layer directly in the layers object in layers.js, or declare it separately 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. sampleLayers.js has even more features and comments in it. You can use those 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!"**
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.
###Table of Contents:
- [Basic layer breakdown](docs/basic-layer-breakdown.md): Breaking down the components of a layer with minimal features.
- [Layer features](docs/layer-features.md): Explanations of all of the different properties a layer can be given in layer config.
- [Upgrades](docs/upgrades.md): How to create upgrades for a layer.
- [Milestones](docs/milestones.md): How to create milestones for a layer.
- [Challenges](docs/challenges.md): How to create challenges for a layer.
- [Buyables](docs/buyables.md): Create rebuyable upgrades for your layer (with the option to make them respec-able). Can be used to make Enhancers or Space Buildings.
- [Customized Tab Layouts](docs/custom-tab-layouts.md): An optional way to give your tabs a different layout. You can even create entirely new components to use.
Layer features! In no particular order
-----Layer-defining features-----
startData() - Returns an object containing the default values for any saved data in this layer, including resources, toggles, upgrades, and more.
Required:
unl: a bool determining if it is unlocked or not
points: a Decimal, the main currency for the layer
Useful:
total: A decimal, tracks total amount of main currency
best: A decimal, tracks highest amount of main currency
order: used to keep track of relevant layers unlocked before this one.
upgrades, milestones, challs: Empty arrays. Needed if you are using the corresponding feature in this layer
color: A color associated with this layer, used in many places. (A string in hex format with a #)
row: The row of the layer
resource: Name of the main currency you gain by resetting on this layer.
effect() - Optional, returns the current strength of any effects derived from the layer's main currency
effectDescription() - Optional, returns a description of the effect this layer has
tabFormat: Optional. If you use this, you can make a custom layout for your tab, using any components defined in vue.js.
-----Prestige formula features-----
baseResource: The resource that determines how much of the main currency you gain on reset.
baseAmount() - How you get the current value of baseResource (e.g. baseAmount() {player.points})
requires() - A function that determines how much base resource you need to reset as a Decimal value. It can return a constant value, or change based on your order.
type: can be "normal" or "static". "normal" means the amount of currency you gain is independent of its current amount (like Prestige). "static" means that the cost grows depending on how much you already have (like Boosters). They both use different formulas. normal = x^exponent, static is base^(x^exponent)
exponent: Prestige currency exponent
base: Prestige currency base, only needed for "static" layers
resCeil: Bool, true if the resource needs to be rounded up
canBuyMax() - Only needed for static layers, used to determine if buying max is permitted.
gainMult(), gainExp() - Used to determine the multiplier and exponent on resource gain from upgrades and boosts and such. Plug all of them in here.
onPrestige(gain) - Optional, Triggers when this layer prestiges, just before you gain the currency. Can be used to have secondary resource gain on prestige, or to recalculate things or whatnot.
-----Other features-----
doReset(resettingLayer) - Optional, is triggered when a layer on a row greater than or equal to this one. 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 higher layer.
convertToDecimal() - Only needed if you have non-standard Decimal values in startData, to these values from strings to Decimals after loading.
layerShown() - Returns a bool determining if this layer's node should be visible on the tree.
update(diff) - Optional, part of the main loop, use it for any passive resource production or time-based things. diff is the time since the last update. Suggestion: use addPoints(layer, gain) when generating points to automatically update the best and total amounts.
automate() - Optional, use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate.
updateTemp() - Optional, use it to update anything in the "temp" object.
resetsNothing() - Optional, returns true if this layer shouldn't trigger any resets.
incr_order: Optional, an array of layer names, their order will increase by 1 when this one is first unlocked. Can be empty.
branches: Optional, an array of pairs consisting of a layer name and a number from 1 to 3. When this layer is visible, for each pair, there will be a branch from this layer to the other layer with a color determined by the number.
-----Upgrades-----
Upgrades are stored in the following format:
upgrades: {
rows: # of rows
cols: # of columns
11: {
[insert upgrade info here]
}
etc
}
Each upgrade should have an id where the first digit is the row and the second digit is the column. Individual upgrades can have these features:
desc: A description of the upgrade's effect
effect() - Optional, calculate and return the values of this upgrade's effects or effects.
effectDisp() - Optional, returns a display of the current effects of the upgrade with formatting. Default behavior is to just display the number appropriately formatted.
cost: A Decimal for the cost of the upgrade.
currencyDisplayName: Optional, if using a currency other than the main one for this layer, the name to display for that currency
currencyInternalName: The internal name for that currency
currencyLayer: The internal name of the layer for that currency. If it's not in a layer (like Points), omit.
unl() - Return a bool to determine if the upgrade is unlocked or not.
onPurchase() - Optional, this function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".
-----Milestones-----
Milestones should be formatted like this:
milestones: {
0: {
[insert milestone info here]
}
etc
}
Milestone features:
requirementDesc: A string describing the requirement
effectDesc: A string describing the reward for having the milestone
done() - A function to determine if the milestone has been fulfilled.
toggles: Creates toggle buttons on the milestone when it is unlocked. An array of paired items, one pair per toggle. The first is the internal name of the layer the value being toggled is stored in, and the second is the internal name of the variable to toggle. (e.g. [["b", "auto"], ["g", "auto"])
-----Challenges-----
Challenges are stored in the following format:
challs: {
rows: # of rows
cols: # of columns
11: {
[insert challenge info here]
}
etc
}
Each challenge should have an id where the first digit is the row and the second digit is the column. Individual upgrades can have these features:
name: Name of the challenge
desc: A description of what makes the challenge a challenge
reward: A description of the reward's effect
effect() - Optional, calculate and return the values of this upgrade's effects or effects.
effectDisp(x) - Optional, returns a display of the current effects of the upgrade with formatting. Default behavior is to just display the number appropriately formatted.
goal: A Decimal for the goal of the challenge's value.
currencyDisplayName: Optional, if using a goal currency other than basic Points, the name to display for that currency
currencyInternalName: The internal name for that currency
currencyLayer: The internal name of the layer for that currency. If it's not in a layer, omit.
unl() - Return a bool to determine if the challenge is unlocked or not.
onComplete() - Optional, this function will be called when the challenge is newly completed.
countsAs: An array of ids of other challenges in this layer that being in this challenge "counts as" being in.

77
docs/layer-features Normal file
View file

@ -0,0 +1,77 @@
#Layer Features
This is a more comprehensive list of established features to add to layers.
You can add more freely, if you want to have other functions or values associated with your layer. These have special functionality, though.
#Layer-defining features
- startData: A function to return the default save data for this layer. Add any variables you have to it.
Any nonstandard Decimal variables need to be added to convertToDecimal as well.
Required values:
unl: a bool determining if it is unlocked or not
points: a Decimal, the main currency for the layer
Useful:
total: A decimal, tracks total amount of main prestige currency
best: A decimal, tracks highest amount of main prestige currency
order: used to keep track of relevant layers unlocked before this one.
- color: A color associated with this layer, used in many places. (A string in hex format with a #)
- row: The row of the layer, starting at 0.
- resource: Name of the main currency you gain by resetting on this layer.
- effect: **optional**, A function that calculates and returns the current values of any bonuses inherent to the main currency.
Returns a value or an object containing multiple values.
- effectDescription: **optional**, A function that returns a description of this effect
- style: A CSS object containing any CSS that should affect this layer's whole tab.
- [tabFormat: Use this if you want to add extra things to your tab or change the layout. Explanations are in a separate file.](docs/custom-tab-layouts.md)
-----Prestige formula features-----
baseResource: The resource that determines how much of the main currency you gain on reset.
baseAmount() - How you get the current value of baseResource (e.g. baseAmount() {player.points})
requires() - A function that determines how much base resource you need to reset as a Decimal value. It can return a constant value, or change based on your order.
type: can be "normal" or "static". "normal" means the amount of currency you gain is independent of its current amount (like Prestige). "static" means that the cost grows depending on how much you already have (like Boosters). They both use different formulas. normal = x^exponent, static is base^(x^exponent)
exponent: Prestige currency exponent
base: Prestige currency base, only needed for "static" layers
resCeil: Bool, true if the resource needs to be rounded up
canBuyMax() - Only needed for static layers, used to determine if buying max is permitted.
gainMult(), gainExp() - Used to determine the multiplier and exponent on resource gain from upgrades and boosts and such. Plug all of them in here.
onPrestige(gain) - Optional, Triggers when this layer prestiges, just before you gain the currency. Can be used to have secondary resource gain on prestige, or to recalculate things or whatnot.
-----Other features-----
doReset(resettingLayer) - Optional, is triggered when a layer on a row greater than or equal to this one. 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 higher layer.
convertToDecimal() - Only needed if you have non-standard Decimal values in startData, to these values from strings to Decimals after loading.
layerShown() - Returns a bool determining if this layer's node should be visible on the tree.
update(diff) - Optional, part of the main loop, use it for any passive resource production or time-based things. diff is the time since the last update. Suggestion: use addPoints(layer, gain) when generating points to automatically update the best and total amounts.
automate() - Optional, use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate.
updateTemp() - Optional, use it to update anything in the "temp" object.
resetsNothing() - Optional, returns true if this layer shouldn't trigger any resets.
incr_order: Optional, an array of layer names, their order will increase by 1 when this one is first unlocked. Can be empty.
branches: Optional, an array of pairs consisting of a layer name and a number from 1 to 3. When this layer is visible, for each pair, there will be a branch from this layer to the other layer with a color determined by the number.

View file

@ -125,6 +125,7 @@
<h2 id="points">{{format(player.points)}}</h2>
<span v-if="player.points.lt('1e1e6')"> {{modInfo.pointsName}}</span>
<br><br><br><br><br>
<!-- *************************** Modify the tree in the table below! *************************** -->
<table>
<td><layer-node layer='c' abb='C'></layer-node></td>
</table><table>

View file

@ -33,7 +33,9 @@ function getStartPlayer() {
playerdata[layer] = layers[layer].startData()
playerdata[layer].buyables = getStartBuyables(layer)
playerdata[layer].spentOnBuyables = new Decimal(0)
playerdata[layer].upgrades = []
playerdata[layer].milestones = []
playerdata[layer].challs = []
}
return playerdata
}
@ -65,6 +67,12 @@ function fixSave() {
}
for (layer in layers) {
defaultData = layers[layer].startData()
if (player[layer].upgrades == undefined)
player[layer].upgrades = []
if (player[layer].milestones == undefined)
player[layer].milestones = []
if (player[layer].challs == undefined)
player[layer].challs = []
for (datum in defaultData){
if (player[layer][datum] == undefined){
@ -309,6 +317,9 @@ function rowReset(row, layer) {
function fullLayerReset(layer) {
player[layer] = layers[layer].startData();
player[layer].upgrades = []
player[layer].milestones = []
player[layer].challs = []
resetBuyables(layer)
}
@ -398,6 +409,19 @@ function canAffordUpg(layer, id) {
return canAffordPurchase(layer, upg, cost)
}
function hasUpg(layer, id){
return (player[layer].upgrades.includes(id))
}
function hasMilestone(layer, id){
return (player[layer].milestones.includes(id))
}
function hasChall(layer, id){
return (player[layer].challs.includes(id))
}
function canAffordPurchase(layer, thing, cost) {
if (thing.currencyInternalName){
let name = thing.currencyInternalName
@ -718,7 +742,6 @@ document.onkeydown = function(e) {
if (ctrlDown) key = "ctrl+" + key
if (onFocused) return
if (ctrlDown && key != "-" && key != "_" && key != "+" && key != "=" && key != "r" && key != "R" && key != "F5") e.preventDefault()
console.log(key)
if(hotkeys[key]){
if (player[hotkeys[key].layer].unl)
hotkeys[key].onPress()

View file

@ -5,8 +5,6 @@ var layers = {
points: new Decimal(0),
best: new Decimal(0),
total: new Decimal(0),
upgrades: [],
milestones: [],
buyables: {}, // You don't actually have to initialize this one
beep: false,
}},
@ -173,7 +171,6 @@ var layers = {
baseAmount() {return player.points},
type: "normal",
exponent: 0.5,
resCeil: false,
gainMult() {
return new Decimal(1)
},

View file

@ -6,9 +6,6 @@ var layers = {
best: new Decimal(0),
total: new Decimal(0),
order: 0, // Used for tracking other relevant layers unlocked before this one
upgrades: [],
milestones: [],
challs: [],
beep:false,
}},
color: "#4BEC13",