From 62edbcae09fbdc01dcae1c84c9ca9e22da10c0e6 Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Thu, 1 Oct 2020 15:57:47 -0400 Subject: [PATCH] Docs: Switched code blocks to JS, added clarifications --- docs/!general-info.md | 5 +++-- docs/basic-layer-breakdown.md | 5 ++++- docs/buyables.md | 2 ++ docs/challenges.md | 2 ++ docs/custom-tab-layouts.md | 3 ++- docs/layer-features.md | 8 ++++++-- docs/milestones.md | 2 ++ docs/upgrades.md | 2 ++ 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/!general-info.md b/docs/!general-info.md index 3e72637..acd0279 100644 --- a/docs/!general-info.md +++ b/docs/!general-info.md @@ -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: diff --git a/docs/basic-layer-breakdown.md b/docs/basic-layer-breakdown.md index c9ce769..e19e3a9 100644 --- a/docs/basic-layer-breakdown.md +++ b/docs/basic-layer-breakdown.md @@ -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. - }, \ No newline at end of file + }, +``` \ No newline at end of file diff --git a/docs/buyables.md b/docs/buyables.md index d776fd6..d0a3137 100644 --- a/docs/buyables.md +++ b/docs/buyables.md @@ -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: diff --git a/docs/challenges.md b/docs/challenges.md index bbc9a06..8bd704a 100644 --- a/docs/challenges.md +++ b/docs/challenges.md @@ -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. diff --git a/docs/custom-tab-layouts.md b/docs/custom-tab-layouts.md index f1ed5e8..186425b 100644 --- a/docs/custom-tab-layouts.md +++ b/docs/custom-tab-layouts.md @@ -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 ""}], @@ -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. diff --git a/docs/layer-features.md b/docs/layer-features.md index e502531..c8a982d 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -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. diff --git a/docs/milestones.md b/docs/milestones.md index 60b91bb..83a00d5 100644 --- a/docs/milestones.md +++ b/docs/milestones.md @@ -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, diff --git a/docs/upgrades.md b/docs/upgrades.md index b54fa5f..bc493a5 100644 --- a/docs/upgrades.md +++ b/docs/upgrades.md @@ -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".