mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2025-01-30 23:21:49 +00:00
Added more capabilities in mod.js and fixed a number format issue
This commit is contained in:
parent
9352a12219
commit
58f181e70f
5 changed files with 58 additions and 22 deletions
|
@ -1,9 +1,14 @@
|
||||||
# The Modding Tree changelog:
|
# The Modding Tree changelog:
|
||||||
|
|
||||||
|
## v2.1: Non-nonsensical - 10/x/20
|
||||||
- Moved most of the code users will want to edit to mod.js.
|
- Moved most of the code users will want to edit to mod.js.
|
||||||
- Added getStartPoints()
|
- 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.
|
||||||
- Added "sell one" and "sell all" buttons for buyables.
|
- Added "sell one" and "sell all" buttons for buyables.
|
||||||
- Fixed issues with version number
|
- Fixed issues with version number
|
||||||
|
- Fixed number formatting issue making things like "10e9" appear.
|
||||||
|
|
||||||
|
|
||||||
### v2.0.5 - 10/16/20
|
### v2.0.5 - 10/16/20
|
||||||
- Made more features (including prestige parameters) able to be dynamic.
|
- Made more features (including prestige parameters) able to be dynamic.
|
||||||
|
|
30
index.html
30
index.html
|
@ -85,7 +85,7 @@
|
||||||
<td><button class="opt" onclick="toggleOpt('hqTree')">High-Quality Tree: {{ player.hqTree?"ON":"OFF" }}</button></td>
|
<td><button class="opt" onclick="toggleOpt('hqTree')">High-Quality Tree: {{ player.hqTree?"ON":"OFF" }}</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><button class="opt" onclick="toggleOpt('hideChallengess')">Completed Challenges: {{ player.hideChallenges?"HIDDEN":"SHOWN" }}</button></td>
|
<td><button class="opt" onclick="toggleOpt('hideChallenges')">Completed Challenges: {{ player.hideChallenges?"HIDDEN":"SHOWN" }}</button></td>
|
||||||
<!-- <td><button class="opt" onclick="toggleOpt('oldStyle')">Style: {{ player.oldStyle?"v1.0":"NEW" }}</button></td>-->
|
<!-- <td><button class="opt" onclick="toggleOpt('oldStyle')">Style: {{ player.oldStyle?"v1.0":"NEW" }}</button></td>-->
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -111,6 +111,7 @@
|
||||||
<span v-if="player.points.lt('1e1e6')" class="overlayThing"> {{modInfo.pointsName}}</span>
|
<span v-if="player.points.lt('1e1e6')" class="overlayThing"> {{modInfo.pointsName}}</span>
|
||||||
<br>
|
<br>
|
||||||
<span v-if="canGenPoints()" class="overlayThing">({{format(getPointGen())}}/sec)</span>
|
<span v-if="canGenPoints()" class="overlayThing">({{format(getPointGen())}}/sec)</span>
|
||||||
|
<div v-for="thing in tmp.displayThings" class="overlayThing"><span v-if="thing" v-html="thing"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sideLayers" >
|
<div class="sideLayers" >
|
||||||
<div v-for="node in OTHER_LAYERS['side']"><layer-node :layer='node.layer' :abb='layers[node.layer].symbol' :size="'small'"></layer-node></div>
|
<div v-for="node in OTHER_LAYERS['side']"><layer-node :layer='node.layer' :abb='layers[node.layer].symbol' :size="'small'"></layer-node></div>
|
||||||
|
@ -121,21 +122,22 @@
|
||||||
<div id="treeTab" style="z-index: 0" v-if="player.tab!='gameEnded'" onscroll="resizeCanvas()" v-bind:class="{ fullWidth: player.tab == 'tree', col: player.tab != 'tree', left: player.tab != 'tree'}">
|
<div id="treeTab" style="z-index: 0" v-if="player.tab!='gameEnded'" onscroll="resizeCanvas()" v-bind:class="{ fullWidth: player.tab == 'tree', col: player.tab != 'tree', left: player.tab != 'tree'}">
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
<div id="fakeHead" style="visibility: hidden;">
|
<div id="fakeHead" style="visibility: hidden;">
|
||||||
<span v-if="player.devSpeed && player.devSpeed != 1">
|
<span v-if="player.devSpeed && player.devSpeed != 1" class="overlayThing">
|
||||||
<br>12<br>
|
<br>Dev Speed: {{format(player.devSpeed)}}x<br>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="player.offTime !== undefined">
|
<span v-if="player.offTime !== undefined" class="overlayThing">
|
||||||
<br>12<br>
|
<br>Offline Time: {{formatTime(player.offTime.remain)}}<br>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="false && !player.keepGoing">
|
<span v-if="false && !player.keepGoing" class="overlayThing">
|
||||||
<br>12<br>
|
<br>Reach {{formatWhole(ENDGAME)}} to beat the game!<br>
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
<span v-if="player.points.lt('1e1000')">a</span>
|
<span v-if="player.points.lt('1e1000')" class="overlayThing">You have </span>
|
||||||
<h2 id="points">12345</h2>
|
<h2 class="overlayThing" id="points">{{format(player.points)}}</h2>
|
||||||
<span v-if="player.points.lt('1e1e6')"> 1</span>
|
<span v-if="player.points.lt('1e1e6')" class="overlayThing"> {{modInfo.pointsName}}</span>
|
||||||
<br>
|
<br>
|
||||||
<span v-if="canGenPoints()">1</span>
|
<span v-if="canGenPoints()" class="overlayThing">({{format(getPointGen())}}/sec)</span>
|
||||||
|
<div v-for="thing in tmp.displayThings" class="overlayThing"><span v-if="thing" v-html="thing"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<span v-for="row in TREE_LAYERS"><table>
|
<span v-for="row in TREE_LAYERS"><table>
|
||||||
<td v-if="player.tab=='tree'&& someLayerUnlocked(row) && row != 0" class="left"><br><br><img class="remove" src="remove.png" onclick="resetRow(row)"></img></td>
|
<td v-if="player.tab=='tree'&& someLayerUnlocked(row) && row != 0" class="left"><br><br><img class="remove" src="remove.png" onclick="resetRow(row)"></img></td>
|
||||||
|
@ -145,7 +147,7 @@
|
||||||
<canvas id="treeCanvas" class="canvas"></canvas>
|
<canvas id="treeCanvas" class="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="layer in LAYERS" >
|
<div v-for="layer in LAYERS" >
|
||||||
<div v-if="player.tab==layer" v-bind:class="'col right fast tab'" v-bind:style="[tmp[layer].style ? tmp[layer].style : {}, (layers[layer].tabFormat && !Array.isArray(layers[layer].tabFormat)) ? tmp[layer].tabFormat[player.subtabs[layer].mainTabs].style : {}]">
|
<div v-if="player.tab==layer" v-bind:class="'col right fast tab'" v-bind:style="[tmp[layer].style ? tmp[layer].style : {}, (layers[layer].tabFormat && !Array.isArray(tmp[layer].tabFormat)) ? tmp[layer].tabFormat[player.subtabs[layer].mainTabs].style : {}]">
|
||||||
<button class="back" onclick="showTab('tree')">←</button><br><br><br>
|
<button class="back" onclick="showTab('tree')">←</button><br><br><br>
|
||||||
<div v-if="!layers[layer].tabFormat">
|
<div v-if="!layers[layer].tabFormat">
|
||||||
<main-display v-bind:style="tmp[layer].componentStyles['main-display']" :layer="layer"></main-display>
|
<main-display v-bind:style="tmp[layer].componentStyles['main-display']" :layer="layer"></main-display>
|
||||||
|
@ -157,7 +159,7 @@
|
||||||
<span v-if="player[layer].best != undefined">Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}<br></span>
|
<span v-if="player[layer].best != undefined">Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}<br></span>
|
||||||
<span v-if="player[layer].total != undefined">You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}<br></span>
|
<span v-if="player[layer].total != undefined">You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}<br></span>
|
||||||
<milestones v-bind:style="tmp[layer].componentStyles.milestones" :layer="layer"></milestones>
|
<milestones v-bind:style="tmp[layer].componentStyles.milestones" :layer="layer"></milestones>
|
||||||
<div v-if="Array.isArray(layers[layer].midsection)">
|
<div v-if="Array.isArray(tmp[layer].midsection)">
|
||||||
<column :layer="layer" :data="tmp[layer].midsection"></column>
|
<column :layer="layer" :data="tmp[layer].midsection"></column>
|
||||||
</div>
|
</div>
|
||||||
<clickables v-bind:style="tmp[layer].componentStyles['clickables']" :layer="layer"></clickables>
|
<clickables v-bind:style="tmp[layer].componentStyles['clickables']" :layer="layer"></clickables>
|
||||||
|
@ -167,7 +169,7 @@
|
||||||
<br><br>
|
<br><br>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="layers[layer].tabFormat">
|
<div v-if="layers[layer].tabFormat">
|
||||||
<div v-if="Array.isArray(layers[layer].tabFormat)">
|
<div v-if="Array.isArray(tmp[layer].tabFormat)">
|
||||||
<column :layer="layer" :data="tmp[layer].tabFormat"></column>
|
<column :layer="layer" :data="tmp[layer].tabFormat"></column>
|
||||||
</div>
|
</div>
|
||||||
<div v-else v-bind:style="[{'margin-top': '-50px'}]">
|
<div v-else v-bind:style="[{'margin-top': '-50px'}]">
|
||||||
|
|
14
js/mod.js
14
js/mod.js
|
@ -15,7 +15,8 @@ let VERSION = {
|
||||||
name: "Non-nonsensical!",
|
name: "Non-nonsensical!",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the names of functions that do something when you call them here. (The ones here are examples)
|
// If you add new functions anywhere inside of a layer, and those functions have an effect when called, add them here.
|
||||||
|
// (The ones here are examples, all official functions are already taken care of)
|
||||||
var doNotCallTheseFunctionsEveryTick = ["doReset", "buy", "onPurchase", "blowUpEverything"]
|
var doNotCallTheseFunctionsEveryTick = ["doReset", "buy", "onPurchase", "blowUpEverything"]
|
||||||
|
|
||||||
function getStartPoints(){
|
function getStartPoints(){
|
||||||
|
@ -37,7 +38,18 @@ function getPointGen() {
|
||||||
return gain
|
return gain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// You can add non-layer related variables that should to into "player" and be saved here, along with default values
|
||||||
|
function addedPlayerData() { return {
|
||||||
|
weather: "Yes",
|
||||||
|
happiness: new Decimal(72),
|
||||||
|
}}
|
||||||
|
|
||||||
|
// Display extra things at the top of the page
|
||||||
|
var displayThings = [
|
||||||
|
function() {if (player.points.eq(69)) return "Tee hee!"},
|
||||||
|
function() {if (player.f.points.gt(1)) return `You have ${player.f.points} farm points. (Which do nothing.)`},
|
||||||
|
function() {if (inChallenge("c", 11)) return "The game is currently <h1>0%</h1> harder."},
|
||||||
|
]
|
||||||
|
|
||||||
// Less important things beyond this point!
|
// Less important things beyond this point!
|
||||||
|
|
||||||
|
|
14
js/temp.js
14
js/temp.js
|
@ -14,8 +14,10 @@ for (item in noCall) {
|
||||||
|
|
||||||
function setupTemp() {
|
function setupTemp() {
|
||||||
tmp = {}
|
tmp = {}
|
||||||
setupTempData(layers, tmp)
|
tmp.pointGen = {}
|
||||||
|
tmp.displayThings = []
|
||||||
|
|
||||||
|
setupTempData(layers, tmp)
|
||||||
for (layer in layers){
|
for (layer in layers){
|
||||||
tmp[layer].resetGain = {}
|
tmp[layer].resetGain = {}
|
||||||
tmp[layer].nextAt = {}
|
tmp[layer].nextAt = {}
|
||||||
|
@ -28,9 +30,6 @@ function setupTemp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupTempData(layerData, tmpData) {
|
function setupTempData(layerData, tmpData) {
|
||||||
tmp.pointGen = {}
|
|
||||||
|
|
||||||
|
|
||||||
for (item in layerData){
|
for (item in layerData){
|
||||||
if (layerData[item] == null) {
|
if (layerData[item] == null) {
|
||||||
tmpData[item] = null
|
tmpData[item] = null
|
||||||
|
@ -70,6 +69,13 @@ function updateTemp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.pointGen = getPointGen()
|
tmp.pointGen = getPointGen()
|
||||||
|
tmp.displayThings = []
|
||||||
|
for (thing in displayThings){
|
||||||
|
let text = displayThings[thing]
|
||||||
|
if (isFunction(text)) text = text()
|
||||||
|
tmp.displayThings.push(text)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTempData(layerData, tmpData) {
|
function updateTempData(layerData, tmpData) {
|
||||||
|
|
17
js/utils.js
17
js/utils.js
|
@ -3,7 +3,11 @@
|
||||||
function exponentialFormat(num, precision) {
|
function exponentialFormat(num, precision) {
|
||||||
let e = num.log10().floor()
|
let e = num.log10().floor()
|
||||||
let m = num.div(Decimal.pow(10, e))
|
let m = num.div(Decimal.pow(10, e))
|
||||||
return m.toStringWithDecimalPlaces(3)+"e"+e.toStringWithDecimalPlaces(0)
|
if(m.toStringWithDecimalPlaces(precision) == 10) {
|
||||||
|
m = new Decimal(1)
|
||||||
|
e = e.add(1)
|
||||||
|
}
|
||||||
|
return m.toStringWithDecimalPlaces(precision)+"e"+e.toStringWithDecimalPlaces(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
function commaFormat(num, precision) {
|
function commaFormat(num, precision) {
|
||||||
|
@ -34,7 +38,7 @@ function format(decimal, precision=2) {
|
||||||
var slog = decimal.slog()
|
var slog = decimal.slog()
|
||||||
if (slog.gte(1e6)) return "F" + format(slog.floor())
|
if (slog.gte(1e6)) return "F" + format(slog.floor())
|
||||||
else return Decimal.pow(10, slog.sub(slog.floor())).toStringWithDecimalPlaces(3) + "F" + commaFormat(slog.floor(), 0)
|
else return Decimal.pow(10, slog.sub(slog.floor())).toStringWithDecimalPlaces(3) + "F" + commaFormat(slog.floor(), 0)
|
||||||
} else if (decimal.gte("1e1000")) return (Math.floor(decimal.mantissa + 0.01) + ("e"+formatWhole(decimal.log10().floor())))
|
} else if (decimal.gte("1e1000")) return exponentialFormat(decimal, 0)
|
||||||
else if (decimal.gte(1e9)) return exponentialFormat(decimal, precision)
|
else if (decimal.gte(1e9)) return exponentialFormat(decimal, precision)
|
||||||
else if (decimal.gte(1e3)) return commaFormat(decimal, 0)
|
else if (decimal.gte(1e3)) return commaFormat(decimal, 0)
|
||||||
else return commaFormat(decimal, precision)
|
else return commaFormat(decimal, precision)
|
||||||
|
@ -86,6 +90,11 @@ function startPlayerBase() {
|
||||||
|
|
||||||
function getStartPlayer() {
|
function getStartPlayer() {
|
||||||
playerdata = startPlayerBase()
|
playerdata = startPlayerBase()
|
||||||
|
extradata = addedPlayerData()
|
||||||
|
|
||||||
|
for (thing in extradata)
|
||||||
|
playerdata[thing] = extradata[thing]
|
||||||
|
|
||||||
for (layer in layers){
|
for (layer in layers){
|
||||||
playerdata[layer] = layers[layer].startData()
|
playerdata[layer] = layers[layer].startData()
|
||||||
playerdata[layer].buyables = getStartBuyables(layer)
|
playerdata[layer].buyables = getStartBuyables(layer)
|
||||||
|
@ -500,7 +509,9 @@ function clickClickable(layer, id) {
|
||||||
// Function to determine if the player is in a challenge
|
// Function to determine if the player is in a challenge
|
||||||
function inChallenge(layer, id){
|
function inChallenge(layer, id){
|
||||||
let challenge = player[layer].activeChallenge
|
let challenge = player[layer].activeChallenge
|
||||||
if (challenge==toNumber(id)) return true
|
if (challenge == null) return
|
||||||
|
id = toNumber(id)
|
||||||
|
if (challenge==id) return true
|
||||||
|
|
||||||
if (layers[layer].challenges[challenge].countsAs)
|
if (layers[layer].challenges[challenge].countsAs)
|
||||||
return tmp[layer].challenges[id].countsAs.includes(id)
|
return tmp[layer].challenges[id].countsAs.includes(id)
|
||||||
|
|
Loading…
Add table
Reference in a new issue