mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-21 16:13:55 +00:00
Added documentation on mod.js
This commit is contained in:
parent
a50ed331bf
commit
2316e3e635
4 changed files with 71 additions and 7 deletions
|
@ -1,7 +1,8 @@
|
|||
# The Modding Tree changelog:
|
||||
|
||||
## v2.1: Non-nonsensical - 10/x/20
|
||||
- Moved most of the code users will want to edit to mod.js.
|
||||
## v2.1: We should have thought of this sooner! - 10/17/20
|
||||
- Moved most of the code users will want to edit to mod.js, added documentation for it.
|
||||
- Specifically, modInfo, VERSION, canGenPoints, getPointGen, and maxTickLength
|
||||
- Added getStartPoints()
|
||||
- Added the ability to store non-layer-related data
|
||||
- Added the ability to display more things at the top of the tree tab below points.
|
||||
|
|
|
@ -25,6 +25,7 @@ All display text can be basic HTML instead (But you can't use most Vue features
|
|||
## Table of Contents:
|
||||
|
||||
- [Getting Started](getting-started.md): Getting your own copy of the code set up with Github Desktop.
|
||||
- [Main mod info](main-mod-info.md): How to set up general things for your mod in mod.js.
|
||||
- [Basic layer breakdown](basic-layer-breakdown.md): Breaking down the components of a layer with minimal features.
|
||||
- [Layer features](layer-features.md): Explanations of all of the different properties that you can give a layer.
|
||||
- [Upgrades](upgrades.md): How to create upgrades for a layer.
|
||||
|
|
61
docs/main-mod-info.md
Normal file
61
docs/main-mod-info.md
Normal file
|
@ -0,0 +1,61 @@
|
|||
# mod.js
|
||||
|
||||
All of the code and data that you're likely to edit is here in mod.js! Everything in mod.js
|
||||
will not be altered by updates, besides the addition of new things.
|
||||
|
||||
Here's a breakdown of what's in it:
|
||||
|
||||
|
||||
- modInfo is where most of the basic configuration for the mod is. It contains:
|
||||
- name: The name of your mod. (a string)
|
||||
- id: The id for your mod, a unique string that is used to determine savefile location. Setting it is important!
|
||||
- pointsName: This changes what is displayed instead of "points" for the main currency. (It does not affect it in the code.)
|
||||
- discordName, discordLink: If you have a Discord server or other discussion place, you can add a link to it.
|
||||
"discordName" is the text on the link, and "discordLink" is the url of an invite.
|
||||
If you're using a Discord invite, please make sure it's set to never expire.
|
||||
- changelogLink: You can use this to set a link to a page where your changelog for the game is displayed.
|
||||
- offlineLimit: The maximum amount of offline time that the player can accumulate, in hours. Any extra time is lost. (a number)
|
||||
This is useful because most of these mods are fast-paced enough that too much offline time ruins the balance,
|
||||
such as the time in between updates.
|
||||
That is why I suggest developers disable offline time on their own savefile.
|
||||
- initialStartPoints: A Decimal for the amount of points a new player should start with.
|
||||
|
||||
- VERSION is used to describe the current version of your mod. It contains:
|
||||
num: The mod's version number, displayed at the top right of the tree tab.
|
||||
name: The version's name, displayed alongside the number in the info tab.
|
||||
|
||||
- doNotCallTheseFunctionsEveryTick is very important. TMT calls every function anywhere in "layers" every tick to store the result,
|
||||
unless specifically told not to. Functions that have are used to do an action need to be identified. "Official" functions
|
||||
(those in the documentation) are all fine, but if you make any new ones, add their names to this array.
|
||||
|
||||
```js
|
||||
// (The ones here are examples, all official functions are already taken care of)
|
||||
var doNotCallTheseFunctionsEveryTick = ["doReset", "buy", "onPurchase", "blowUpEverything"]
|
||||
```
|
||||
|
||||
- getStartPoints(): A function to determine the amount of points the player starts with after a reset. (returns a Decimal value)
|
||||
|
||||
- canGenPoints(): A function returning a boolean for if points should be generated.
|
||||
Use this if you want an upgrade to unlock generating points.
|
||||
|
||||
- getPointGen(): A function that calculates your points per second. Anything that affects your point gain should go into the calculation here.
|
||||
|
||||
- addedPlayerData(): A function that returns any non-layer-related data that you want to be added to the save data and "player" object.
|
||||
|
||||
```js
|
||||
function addedPlayerData() { return {
|
||||
weather: "Yes",
|
||||
happiness: new Decimal(72),
|
||||
}}
|
||||
```
|
||||
|
||||
- displayThings: An array of functions used to display extra things at the top of the tree tab. Each function returns a string, which
|
||||
is a line to display (with basic HTML support). If a function returns nothing, nothing is displayed (and it doesn't take up a line).
|
||||
|
||||
- isEndgame(): A function to determine if the player has reached the end of the game, at which point the "you win!" screen appears.
|
||||
|
||||
|
||||
Less important things beyond this point!
|
||||
|
||||
- maxTickLength(): Returns the maximum tick length, in milliseconds. Only really useful if you have something that reduces over time,
|
||||
which long ticks mess up (usually a challenge).
|
11
js/utils.js
11
js/utils.js
|
@ -90,11 +90,12 @@ function startPlayerBase() {
|
|||
|
||||
function getStartPlayer() {
|
||||
playerdata = startPlayerBase()
|
||||
extradata = addedPlayerData()
|
||||
|
||||
for (thing in extradata)
|
||||
playerdata[thing] = extradata[thing]
|
||||
|
||||
|
||||
if (addedPlayerData) {
|
||||
extradata = addedPlayerData()
|
||||
for (thing in extradata)
|
||||
playerdata[thing] = extradata[thing]
|
||||
}
|
||||
for (layer in layers){
|
||||
playerdata[layer] = layers[layer].startData()
|
||||
playerdata[layer].buyables = getStartBuyables(layer)
|
||||
|
|
Loading…
Reference in a new issue