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

Docs: Switched code blocks to JS, added clarifications

This commit is contained in:
Acamaeda 2020-10-01 15:57:47 -04:00
parent 7b0e07b7fd
commit 62edbcae09
8 changed files with 23 additions and 6 deletions

View file

@ -2,14 +2,15 @@
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!"**
**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.
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.
The Modding Tree uses break_eternity.js to store large values. This means that many numbers are Decimal objects,
and must be treated differently.
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)`.
## Table of Contents:

View file

@ -2,10 +2,12 @@
This is a very minimal layer with minimal features. Most things will require additional features:
```js
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 of the layer.
// If you add non-standard Decimal variables, look at convertToDecimal
}},
color: "#FE0102", // The color for this layer, which affects many elements
@ -30,4 +32,5 @@ This is a very minimal layer with minimal features. Most things will require add
},
layerShown() {return true}, // Returns a bool for if this layer's node should be visible in the tree.
},
},
```

View file

@ -5,6 +5,7 @@ the player can reset the purchases to get their currency back.
Buyables should be formatted like this:
```js
buyables: {
rows: # of rows
cols: # of columns
@ -17,6 +18,7 @@ Buyables should be formatted like this:
}
etc
}
```
Features:

View file

@ -2,6 +2,7 @@
Challenges are stored in the following format:
```js
challs: {
rows: # of rows
cols: # of columns
@ -11,6 +12,7 @@ Challenges are stored in the following format:
}
etc
}
```
You can use inChall(layer, id) and hasChall(layer, id) to determine if the player is currently in a challenge,
or has completed the challenge, respectively. These are useful for implementing effects.

View file

@ -2,7 +2,7 @@
Custom tab layouts can be used to do basically anything in a tab window, especially combined with the "style" layer feature. The tabFormat feature is an array of things, like this:
```js
tabFormat: ["main-display",
["prestige-button", function(){return "Melt your points into "}],
["raw-html", function() {return "<button onclick='console.log(`yeet`)'>'HI'</button>"}],
@ -12,6 +12,7 @@ Custom tab layouts can be used to do basically anything in a tab window, especia
"blank",
["toggle", ["c", "beep"]],
"milestones", "blank", "blank", "upgrades"]
```
It is a list of components, which can be either just a name, or an array with arguments. If it's an array, the first item is the name of the component, the second is the data passed into it, and the third (optional) is a CSS object,
which applies its style to the component.

View file

@ -37,11 +37,13 @@ Key:
- layerShown(): A function returning a bool which determines if this layer's node should be visible on the tree.
- hotkeys: An array containing information on any hotkeys associated with this layer:
```hotkeys: [
```js
hotkeys: [
{key: "p", // What the hotkey button is. Use uppercase if it's combined with shift, or "ctrl+x" if ctrl is.
desc: "p: reset your points for prestige points", // The description of the hotkey used in the How To Play
onPress(){if (player.p.unl) doReset("p")}}, // This function is called when the hotkey is pressed.
],```
],
```
- style: A CSS object containing any CSS that should affect this layer's whole tab.
@ -105,6 +107,8 @@ Key:
- convertToDecimal(): **sometimes required**, required if you add non-standard Decimals to startData.
This function converts those values from a string to a Decimal (used when loading).
Convert a value to Decimal with `value = new Decimal(value)`
- 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

@ -2,12 +2,14 @@
Milestones should be formatted like this:
```js
milestones: {
0: {
requirementDesc: "123 waffles",
}
etc
}
```
You can use inChall(layer, id) and hasChall(layer, id) to determine if the player is currently in a challenge,

View file

@ -2,6 +2,7 @@
Upgrades are stored in the following format:
```js
upgrades: {
rows: # of rows
cols: # of columns
@ -11,6 +12,7 @@ Upgrades are stored in the following format:
}
etc
}
```
You can use hasUpg(layer, id) to determine if the player has an upgrade. This is useful for implementing bonuses.
Hint: Basic point gain is calculated in game.js's "getPointGain".