From e3fc9756ba5599f2e881d7177669b2e3f4480c7e Mon Sep 17 00:00:00 2001 From: Harley White Date: Fri, 11 Jun 2021 16:22:56 -0400 Subject: [PATCH] Added better support for more files. --- changelog.md | 4 + demo.html | 8 +- docs/main-mod-info.md | 2 + index.html | 5 +- js/Demo/demoMod.js | 6 +- js/Demo/layers/a.js | 65 ++++++++ js/Demo/{demoLayers.js => layers/c.js} | 216 ------------------------- js/Demo/layers/f.js | 147 +++++++++++++++++ js/game.js | 6 +- js/mod.js | 3 +- js/technical/loader.js | 9 ++ 11 files changed, 244 insertions(+), 227 deletions(-) create mode 100644 js/Demo/layers/a.js rename js/Demo/{demoLayers.js => layers/c.js} (71%) create mode 100644 js/Demo/layers/f.js create mode 100644 js/technical/loader.js diff --git a/changelog.md b/changelog.md index 0f4c59b..b40190d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # The Modding Tree changelog: +# v2.6.3 - 6/11/21 +- Added better support for using multiple layer files and similar. See modFiles in modInfo. +- The demo now has each layer in its own file as well. + # v2.6.2.2 - 6/10/21 - Fixed an error message regarding popup.css. diff --git a/demo.html b/demo.html index 144fa28..2b48777 100644 --- a/demo.html +++ b/demo.html @@ -16,10 +16,12 @@ - - + - + + + + diff --git a/docs/main-mod-info.md b/docs/main-mod-info.md index 98932ff..cf2bc21 100644 --- a/docs/main-mod-info.md +++ b/docs/main-mod-info.md @@ -10,6 +10,8 @@ Here's a breakdown of what's in it: - id: The id for your mod, a unique string that is used to determine savefile location. Be sure to set it when you start making a mod, and don't change it later because it will erase all saves. - author: The name of the author, displayed in the info tab. - pointsName: This changes what is displayed instead of "points" for the main currency. (It does not affect it in the code.) + - modFiles: An array of file addresses which will be loaded for this mod. Using smaller files makes it easier to find what you're looking for. + - 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. diff --git a/index.html b/index.html index 977ae2b..2197348 100644 --- a/index.html +++ b/index.html @@ -16,9 +16,10 @@ - - + + + diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js index 95c3cf0..6699f96 100644 --- a/js/Demo/demoMod.js +++ b/js/Demo/demoMod.js @@ -2,16 +2,18 @@ let modInfo = { name: "The Modding Tree", id: "modbase", pointsName: "points", + modFiles: ["Demo/layers/c.js", "Demo/layers/f.js", "Demo/layers/a.js", "Demo/demoTree.js"], + + discordName: "", discordLink: "", initialStartPoints: new Decimal (10), // Used for hard resets and new players - offlineLimit: 1, // In hours } // Set your version in num and name let VERSION = { - num: "2.6.2.2", + num: "2.6.3", name: "Fixed Reality", } diff --git a/js/Demo/layers/a.js b/js/Demo/layers/a.js new file mode 100644 index 0000000..6e391c9 --- /dev/null +++ b/js/Demo/layers/a.js @@ -0,0 +1,65 @@ + +// A side layer with achievements, with no prestige +addLayer("a", { + startData() { return { + unlocked: true, + points: new Decimal(0), + }}, + color: "yellow", + resource: "achievement power", + row: "side", + tooltip() { // Optional, tooltip displays when the layer is locked + return ("Achievements") + }, + achievementPopups: true, + achievements: { + 11: { + image: "discord.png", + name: "Get me!", + done() {return true}, // This one is a freebie + goalTooltip: "How did this happen?", // Shows when achievement is not completed + doneTooltip: "You did it!", // Showed when the achievement is completed + }, + 12: { + name: "Impossible!", + done() {return false}, + goalTooltip: "Mwahahaha!", // Shows when achievement is not completed + doneTooltip: "HOW????", // Showed when the achievement is completed + textStyle: {'color': '#04e050'}, + }, + 13: { + name: "EIEIO", + done() {return player.f.points.gte(1)}, + tooltip: "Get a farm point.\n\nReward: The dinosaur is now your friend (you can max Farm Points).", // Showed when the achievement is completed + onComplete() {console.log("Bork bork bork!")} + }, + }, + midsection: ["grid", "blank"], + grid: { + maxRows: 3, + rows: 2, + cols: 2, + getStartData(id) { + return id + }, + getUnlocked(id) { // Default + return true + }, + getCanClick(data, id) { + return player.points.eq(10) + }, + getStyle(data, id) { + return {'background-color': '#'+ (data*1234%999999)} + }, + onClick(data, id) { // Don't forget onHold + player[this.layer].grid[id]++ + }, + getTitle(data, id) { + return "Gridable #" + id + }, + getDisplay(data, id) { + return data + }, + }, +}, +) \ No newline at end of file diff --git a/js/Demo/demoLayers.js b/js/Demo/layers/c.js similarity index 71% rename from js/Demo/demoLayers.js rename to js/Demo/layers/c.js index 1ecd92d..46b3f24 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/layers/c.js @@ -75,7 +75,6 @@ addLayer("c", { if(hasMilestone(this.layer, this.id)) return { 'background-color': '#1111DD' }}, - }, }, challenges: { @@ -385,221 +384,6 @@ addLayer("c", { resetDescription: "Melt your points into ", }) - - -// This layer is mostly minimal but it uses a custom prestige type and a clickable -addLayer("f", { - infoboxes:{ - coolInfo: { - title: "Lore", - titleStyle: {'color': '#FE0000'}, - body: "DEEP LORE!", - bodyStyle: {'background-color': "#0000EE"} - } - }, - - startData() { return { - unlocked: false, - points: new Decimal(0), - boop: false, - clickables: {[11]: "Start"}, // Optional default Clickable state - }}, - color: "#FE0102", - requires() {return new Decimal(10)}, - resource: "farm points", - baseResource: "points", - baseAmount() {return player.points}, - type: "static", - exponent: 0.5, - base: 3, - roundUpCost: true, - canBuyMax() {return false}, - //directMult() {return new Decimal(player.c.otherThingy)}, - - row: 1, - layerShown() {return true}, - branches: ["c"], // When this layer appears, a branch will appear from this layer to any layers here. Each entry can be a pair consisting of a layer id and a color. - - tooltipLocked() { // Optional, tooltip displays when the layer is locked - return ("This weird farmer dinosaur will only see you if you have at least " + this.requires() + " points. You only have " + formatWhole(player.points)) - }, - midsection: [ - "blank", ['display-image', 'https://images.beano.com/store/24ab3094eb95e5373bca1ccd6f330d4406db8d1f517fc4170b32e146f80d?auto=compress%2Cformat&dpr=1&w=390'], - ["display-text", "Bork bork!"] - ], - // The following are only currently used for "custom" Prestige type: - prestigeButtonText() { //Is secretly HTML - if (!this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you a Farm Point in exchange for all of your points and lollipops! (At least " + formatWhole(tmp[this.layer].nextAt) + " points)" - if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp[this.layer].resetGain) + " Farm Points in exchange for all of your points and lollipops! (You'll get another one at " + formatWhole(tmp[this.layer].nextAtDisp) + " points)" - }, - getResetGain() { - return getResetGain(this.layer, useType = "static") - }, - getNextAt(canMax=false) { // - return getNextAt(this.layer, canMax, useType = "static") - }, - canReset() { - return tmp[this.layer].baseAmount.gte(tmp[this.layer].nextAt) - }, - // This is also non minimal, a Clickable! - clickables: { - - masterButtonPress() { - if (getClickableState(this.layer, 11) == "Borkened...") - player[this.layer].clickables[11] = "Start" - }, - masterButtonText() {return (getClickableState(this.layer, 11) == "Borkened...") ? "Fix the clickable!" : "Does nothing"}, // Text on Respec button, optional - 11: { - title: "Clicky clicky!", // Optional, displayed at the top in a larger font - display() { // Everything else displayed in the buyable button after the title - let data = getClickableState(this.layer, this.id) - return "Current state:
" + data - }, - unlocked() { return player[this.layer].unlocked }, - canClick() { - return getClickableState(this.layer, this.id) !== "Borkened..."}, - onClick() { - switch(getClickableState(this.layer, this.id)){ - case "Start": - player[this.layer].clickables[this.id] = "A new state!" - break; - case "A new state!": - player[this.layer].clickables[this.id] = "Keep going!" - break; - case "Keep going!": - player[this.layer].clickables[this.id] = "Maybe that's a bit too far..." - break; - case "Maybe that's a bit too far...": - makeParticles(coolParticle, 4) - player[this.layer].clickables[this.id] = "Borkened..." - break; - default: - player[this.layer].clickables[this.id] = "Start" - break; - } - }, - onHold(){ - console.log("Clickkkkk...") - }, - style() { - switch(getClickableState(this.layer, this.id)){ - case "Start": - return {'background-color': 'green'} - break; - case "A new state!": - return {'background-color': 'yellow'} - break; - case "Keep going!": - return {'background-color': 'orange'} - break; - case "Maybe that's a bit too far...": - return {'background-color': 'red'} - break; - default: - return {} - break; - }}, - }, - }, - -}, -) - -// A side layer with achievements, with no prestige -addLayer("a", { - startData() { return { - unlocked: true, - points: new Decimal(0), - }}, - color: "yellow", - resource: "achievement power", - row: "side", - tooltip() { // Optional, tooltip displays when the layer is locked - return ("Achievements") - }, - achievementPopups: true, - achievements: { - 11: { - image: "discord.png", - name: "Get me!", - done() {return true}, // This one is a freebie - goalTooltip: "How did this happen?", // Shows when achievement is not completed - doneTooltip: "You did it!", // Showed when the achievement is completed - }, - 12: { - name: "Impossible!", - done() {return false}, - goalTooltip: "Mwahahaha!", // Shows when achievement is not completed - doneTooltip: "HOW????", // Showed when the achievement is completed - textStyle: {'color': '#04e050'}, - }, - 13: { - name: "EIEIO", - done() {return player.f.points.gte(1)}, - tooltip: "Get a farm point.\n\nReward: The dinosaur is now your friend (you can max Farm Points).", // Showed when the achievement is completed - onComplete() {console.log("Bork bork bork!")} - }, - }, - midsection: ["grid", "blank"], - grid: { - maxRows: 3, - rows: 2, - cols: 2, - getStartData(id) { - return id - }, - getUnlocked(id) { // Default - return true - }, - getCanClick(data, id) { - return player.points.eq(10) - }, - getStyle(data, id) { - return {'background-color': '#'+ (data*1234%999999)} - }, - onClick(data, id) { // Don't forget onHold - player[this.layer].grid[id]++ - }, - getTitle(data, id) { - return "Gridable #" + id - }, - getDisplay(data, id) { - return data - }, - }, - }, -) - -const coolParticle = { - image:"options_wheel.png", - spread: 20, - gravity: 2, - time: 3, - rotation (id) { - return 20 * (id - 1.5) + (Math.random() - 0.5) * 10 - }, - dir() { - return (Math.random() - 0.5) * 10 - }, - speed() { - return (Math.random() + 1.2) * 8 - }, - onClick() { - console.log("yay") - }, - onMouseOver() { - console.log("hi") - }, - onMouseLeave() { - console.log("bye") - }, - update() { - //this.width += 1 - //setDir(this, 135) - }, - layer: 'f', -} - const textParticle = { spread: 20, gravity: 0, diff --git a/js/Demo/layers/f.js b/js/Demo/layers/f.js new file mode 100644 index 0000000..7bfce45 --- /dev/null +++ b/js/Demo/layers/f.js @@ -0,0 +1,147 @@ +// This layer is mostly minimal but it uses a custom prestige type and a clickable +addLayer("f", { + infoboxes:{ + coolInfo: { + title: "Lore", + titleStyle: {'color': '#FE0000'}, + body: "DEEP LORE!", + bodyStyle: {'background-color': "#0000EE"} + } + }, + + startData() { return { + unlocked: false, + points: new Decimal(0), + boop: false, + clickables: {[11]: "Start"}, // Optional default Clickable state + }}, + color: "#FE0102", + requires() {return new Decimal(10)}, + resource: "farm points", + baseResource: "points", + baseAmount() {return player.points}, + type: "static", + exponent: 0.5, + base: 3, + roundUpCost: true, + canBuyMax() {return false}, + //directMult() {return new Decimal(player.c.otherThingy)}, + + row: 1, + layerShown() {return true}, + branches: ["c"], // When this layer appears, a branch will appear from this layer to any layers here. Each entry can be a pair consisting of a layer id and a color. + + tooltipLocked() { // Optional, tooltip displays when the layer is locked + return ("This weird farmer dinosaur will only see you if you have at least " + this.requires() + " points. You only have " + formatWhole(player.points)) + }, + midsection: [ + "blank", ['display-image', 'https://images.beano.com/store/24ab3094eb95e5373bca1ccd6f330d4406db8d1f517fc4170b32e146f80d?auto=compress%2Cformat&dpr=1&w=390'], + ["display-text", "Bork bork!"] + ], + // The following are only currently used for "custom" Prestige type: + prestigeButtonText() { //Is secretly HTML + if (!this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you a Farm Point in exchange for all of your points and lollipops! (At least " + formatWhole(tmp[this.layer].nextAt) + " points)" + if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp[this.layer].resetGain) + " Farm Points in exchange for all of your points and lollipops! (You'll get another one at " + formatWhole(tmp[this.layer].nextAtDisp) + " points)" + }, + getResetGain() { + return getResetGain(this.layer, useType = "static") + }, + getNextAt(canMax=false) { // + return getNextAt(this.layer, canMax, useType = "static") + }, + canReset() { + return tmp[this.layer].baseAmount.gte(tmp[this.layer].nextAt) + }, + // This is also non minimal, a Clickable! + clickables: { + + masterButtonPress() { + if (getClickableState(this.layer, 11) == "Borkened...") + player[this.layer].clickables[11] = "Start" + }, + masterButtonText() {return (getClickableState(this.layer, 11) == "Borkened...") ? "Fix the clickable!" : "Does nothing"}, // Text on Respec button, optional + 11: { + title: "Clicky clicky!", // Optional, displayed at the top in a larger font + display() { // Everything else displayed in the buyable button after the title + let data = getClickableState(this.layer, this.id) + return "Current state:
" + data + }, + unlocked() { return player[this.layer].unlocked }, + canClick() { + return getClickableState(this.layer, this.id) !== "Borkened..."}, + onClick() { + switch(getClickableState(this.layer, this.id)){ + case "Start": + player[this.layer].clickables[this.id] = "A new state!" + break; + case "A new state!": + player[this.layer].clickables[this.id] = "Keep going!" + break; + case "Keep going!": + player[this.layer].clickables[this.id] = "Maybe that's a bit too far..." + break; + case "Maybe that's a bit too far...": + makeParticles(coolParticle, 4) + player[this.layer].clickables[this.id] = "Borkened..." + break; + default: + player[this.layer].clickables[this.id] = "Start" + break; + } + }, + onHold(){ + console.log("Clickkkkk...") + }, + style() { + switch(getClickableState(this.layer, this.id)){ + case "Start": + return {'background-color': 'green'} + break; + case "A new state!": + return {'background-color': 'yellow'} + break; + case "Keep going!": + return {'background-color': 'orange'} + break; + case "Maybe that's a bit too far...": + return {'background-color': 'red'} + break; + default: + return {} + break; + }}, + }, + }, + +}, +) + +const coolParticle = { + image:"options_wheel.png", + spread: 20, + gravity: 2, + time: 3, + rotation (id) { + return 20 * (id - 1.5) + (Math.random() - 0.5) * 10 + }, + dir() { + return (Math.random() - 0.5) * 10 + }, + speed() { + return (Math.random() + 1.2) * 8 + }, + onClick() { + console.log("yay") + }, + onMouseOver() { + console.log("hi") + }, + onMouseLeave() { + console.log("bye") + }, + update() { + //this.width += 1 + //setDir(this, 135) + }, + layer: 'f', +} \ No newline at end of file diff --git a/js/game.js b/js/game.js index 936bb9a..5d87334 100644 --- a/js/game.js +++ b/js/game.js @@ -4,7 +4,7 @@ var gameEnded = false; // Don't change this const TMT_VERSION = { - tmtNum: "2.6.2.2", + tmtNum: "2.6.3", tmtName: "Fixed Reality" } @@ -130,11 +130,11 @@ function rowReset(row, layer) { for (lr in ROW_LAYERS[row]){ if(layers[lr].doReset) { - Vue.set(player[lr], "activeChallenge", null) // Exit challenges on any row reset on an equal or higher row + if (!isNaN(row)) Vue.set(player[lr], "activeChallenge", null) // Exit challenges on any row reset on an equal or higher row run(layers[lr].doReset, layers[lr], layer) } else - if(tmp[layer].row > tmp[lr].row && row !== "side" && !isNaN(row)) layerDataReset(lr) + if(tmp[layer].row > tmp[lr].row && !isNaN(row)) layerDataReset(lr) } } diff --git a/js/mod.js b/js/mod.js index ebc7580..6175517 100644 --- a/js/mod.js +++ b/js/mod.js @@ -3,10 +3,11 @@ let modInfo = { id: "mymod", author: "nobody", pointsName: "points", + modFiles: ["layers.js", "tree.js"], + discordName: "", discordLink: "", initialStartPoints: new Decimal (10), // Used for hard resets and new players - offlineLimit: 1, // In hours } diff --git a/js/technical/loader.js b/js/technical/loader.js new file mode 100644 index 0000000..e7c2f91 --- /dev/null +++ b/js/technical/loader.js @@ -0,0 +1,9 @@ +// Load files + +for (file in modInfo.modFiles) { + let script = document.createElement("script"); + script.setAttribute("src", "js/" + modInfo.modFiles[file]); + script.setAttribute("async", "false"); + document.head.insertBefore(script, document.getElementById("temp")); +} +