aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commandManager.js16
-rw-r--r--commands/help.js2
-rw-r--r--commands/setkey.js1
-rw-r--r--commands/throne.js2
-rw-r--r--gui/cwGui.js50
-rw-r--r--gui/settingsGui.js29
-rw-r--r--index.js58
-rw-r--r--metadata.json2
-rw-r--r--util/constants.js4
9 files changed, 104 insertions, 60 deletions
diff --git a/commandManager.js b/commandManager.js
index 4c67142..9acc4e4 100644
--- a/commandManager.js
+++ b/commandManager.js
@@ -7,22 +7,23 @@ import { throne } from "./commands/throne.js"
import { toggle } from "./commands/toggle.js"
import { leaderboard } from "./commands/leaderboard.js"
import { update } from './commands/update'
+import { openCwGui } from './gui/cwGui'
+import Settings from "./gui/settingsGui";
import constants from './util/constants.js'
-import updater from './util/updater'
const PREFIX = constants.PREFIX
register("command", (arg, arg2, arg3) => {
- switch(arg)
+ switch(arg.toLowerCase())
{
- case "setkey":
+ case "setkey":
setkey(arg2)
break
case "help":
help()
break
- case "gui":
- constants.cwGui.open();
+ case "move":
+ openCwGui()
break
case "toggle":
toggle()
@@ -42,6 +43,9 @@ register("command", (arg, arg2, arg3) => {
case "update":
update()
break
+ case "settings":
+ Settings.openGUI()
+ break
default:
ChatLib.chat(`${constants.PREFIX}Finding Coleweight!`)
let username = ""
@@ -61,7 +65,7 @@ register("command", (arg, arg2, arg3) => {
}
}).setTabCompletions((args) => {
let output = [],
- commands = ["setkey", "help", "gui", "toggle", "throne", "spiral", "reload", "leaderboard"]
+ commands = ["setkey", "help", "gui", "toggle", "throne", "spiral", "reload", "leaderboard", "settings"]
if(args[0].length == 0 || args[0] == undefined)
output = commands
diff --git a/commands/help.js b/commands/help.js
index c554294..bc22fda 100644
--- a/commands/help.js
+++ b/commands/help.js
@@ -6,7 +6,7 @@ export function help()
ChatLib.chat("")
ChatLib.chat(`${PREFIX}&b/cw [username] => Gets coleweight`)
ChatLib.chat(`${PREFIX}&b/cw help => This menu.`)
- ChatLib.chat(`${PREFIX}&b/cw gui => Change gui location`)
+ ChatLib.chat(`${PREFIX}&b/cw move => Change gui location`)
ChatLib.chat(`${PREFIX}&b/cw toggle => Toggle gui (gui is only active when mining)`)
ChatLib.chat(`${PREFIX}&b/cw setkey (key) => Sets API key (can also use /api new)`)
ChatLib.chat(`${PREFIX}&b/cw reload => Reloads the gui.`)
diff --git a/commands/setkey.js b/commands/setkey.js
index 8024c0f..530bf28 100644
--- a/commands/setkey.js
+++ b/commands/setkey.js
@@ -1,4 +1,5 @@
import constants from "../util/constants"
+import axios from "../../axios"
const PREFIX = constants.PREFIX
export function setkey(arg2)
diff --git a/commands/throne.js b/commands/throne.js
index 697304d..717ba3c 100644
--- a/commands/throne.js
+++ b/commands/throne.js
@@ -21,8 +21,10 @@ export function throne(arg2)
constants.throneValues.push([startPos[0]+38, startPos[1]-15, startPos[2]+47])
constants.throneValues.push([startPos[0]+41, startPos[1]-44, startPos[2]+46])
constants.throneValues.push([startPos[0]+50, startPos[1]-28, startPos[2]+38])
+ constants.throneValues.push([startPos[0]+55, startPos[1]-36, startPos[2]+29])
constants.throneValues.push([startPos[0]+49, startPos[1]-31, startPos[2]+1])
constants.throneValues.push([startPos[0]+50, startPos[1]-1, startPos[2]+10])
+ constants.throneValues.push([startPos[0]+45, startPos[1]-3, startPos[2]-4])
ChatLib.chat(`${PREFIX}&bThrone waypoints turned on!`)
}
else
diff --git a/gui/cwGui.js b/gui/cwGui.js
new file mode 100644
index 0000000..734593c
--- /dev/null
+++ b/gui/cwGui.js
@@ -0,0 +1,50 @@
+import constants from "../util/constants";
+
+let cwGui = new Gui()
+
+export function openCwGui()
+{
+ cwGui.open()
+}
+
+
+register("dragged", (dx, dy, x, y) => {
+ if (!cwGui.isOpen()) return
+ constants.data.x = x
+ constants.data.y = y
+ constants.data.save()
+});
+
+register("renderOverlay", () => {
+ if (cwGui.isOpen())
+ {
+ let txt = "Please set your api key with /cw setkey (key)!"
+ if (constants.data.api_key != undefined)
+ txt = "Click anywhere to move!"
+ Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2)
+ Renderer.drawStringWithShadow(`&aCW: &b0\n&aCW/hr: &b0\n&aUptime: &b0m\n&aColeweight Gained: &b0`, constants.data.x, constants.data.y)
+ }
+ if(!constants.data.cwToggle || constants.data.api_key == undefined) return
+ let coleweight = constants.data.coleweight || 0,
+ coleweightMessage = ""
+
+ coleweight > 1000 ?coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
+ if(constants.cwValues[0] != undefined && constants.upTimeTrack && constants.calcCwPerHr)
+ {
+ constants.cwValuesSum = 0
+ for(let i = 0; i < constants.cwValues.length; i++)
+ {
+ constants.cwValuesSum += constants.cwValues[i]
+ }
+ let eq = Math.ceil((constants.cwValuesSum*(3600/constants.uptime)) * 100) / 100
+ eq != Infinity ? constants.coleweightHr = eq : constants.coleweightHr = "Calculating..."
+ constants.calcCwPerHr = false
+ }
+
+ if (cwGui.isOpen() || !constants.upTimeTrack) return
+ let uptimeHr = Math.floor(constants.uptime/60/60)
+ if(uptimeHr >= 1)
+ Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${uptimeHr}h ${Math.floor(constants.uptime/60) - uptimeHr*60}m\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y)
+ else
+ Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${Math.floor(constants.uptime/60)}m ${Math.floor(constants.uptime%60)}s\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y)
+}) \ No newline at end of file
diff --git a/gui/settingsGui.js b/gui/settingsGui.js
new file mode 100644
index 0000000..48dbad7
--- /dev/null
+++ b/gui/settingsGui.js
@@ -0,0 +1,29 @@
+import { @Vigilant, @ButtonProperty, @SwitchProperty, @SelectorProperty, @TextProperty } from 'Vigilance'
+import constants from "../util/constants.js"
+
+@Vigilant("Coleweight")
+class Settings {
+ @ButtonProperty({
+ name: "Change tracker position",
+ description: "Move the location of the tracker.",
+ category: "General",
+ placeholder: "Open"
+ })
+ moveLocation() {
+ ChatLib.command("cw move", true);
+ }
+
+ @TextProperty({
+ name: "TBA",
+ description: "TBA; This menu will probably not work while this text is here.",
+ category: "General",
+ protected: false
+ })
+ key = "";
+
+ constructor() {
+ this.initialize(this);
+ }
+}
+
+export default new Settings() \ No newline at end of file
diff --git a/index.js b/index.js
index 2be68ef..2414c4f 100644
--- a/index.js
+++ b/index.js
@@ -2,49 +2,10 @@ import axios from '../axios'
import './commandManager'
import constants from './util/constants';
import "./util/updater"
+import Settings from "./gui/settingsGui.js"
const PREFIX = constants.PREFIX
-//gui
-register("dragged", (dx, dy, x, y) => {
- if (!constants.cwGui.isOpen()) return
- constants.data.x = x
- constants.data.y = y
- constants.data.save()
-});
-
-register("renderOverlay", () => {
- if (constants.cwGui.isOpen()) {
- let txt = "Please set your api key with /cw setkey (key)!"
- if (constants.data.api_key != undefined)
- txt = "Click anywhere to move!"
- Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2)
- Renderer.drawStringWithShadow(`&aCW: &b0\n&aCW/hr: &b0\n&aUptime: &b0m\n&aColeweight Gained: &b0`, constants.data.x, constants.data.y)
- }
- if(!constants.data.cwToggle || constants.data.api_key == undefined) return
- let coleweight = constants.data.coleweight || 0,
- coleweightMessage = ""
-
- coleweight > 1000 ?coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
- if(constants.cwValues[0] != undefined && constants.upTimeTrack && constants.calcCwPerHr)
- {
- constants.cwValuesSum = 0
- for(let i = 0; i < constants.cwValues.length; i++)
- {
- constants.cwValuesSum += constants.cwValues[i]
- }
- let eq = Math.ceil((constants.cwValuesSum*(3600/constants.uptime)) * 100) / 100
- eq != Infinity ? constants.coleweightHr = eq : constants.coleweightHr = "Calculating..."
- constants.calcCwPerHr = false
- }
-
- if (constants.cwGui.isOpen() || !constants.upTimeTrack) return
- let uptimeHr = Math.floor(constants.uptime/60/60)
- if(uptimeHr >= 1)
- Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${uptimeHr}h ${Math.floor(constants.uptime/60) - uptimeHr}m\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y)
- else
- Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${constants.coleweightHr}\n&aUptime: &b${Math.floor(constants.uptime/60)}m ${Math.floor(constants.uptime%60)}s\n&aColeweight Gained: &b${Math.ceil(constants.cwValuesSum*100) / 100}`, constants.data.x, constants.data.y)
-})
//world update (coords)
register("renderWorld", () => {
@@ -65,21 +26,18 @@ register("renderWorld", () => {
})
-//update checker
-
-
//update every second (dogshit code)
register("step", () => {
// first time check
if (constants.data.first_time)
{
- constants.data.first_time = false;
- constants.data.save();
- ChatLib.chat("");
- new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bPlease Set Your Api Key By Doing /api new`)).chat();
- new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bOr By Doing /cw setkey (key)`)).chat();
- new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat();
- ChatLib.chat("");
+ constants.data.first_time = false
+ constants.data.save()
+ ChatLib.chat("")
+ new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bPlease Set Your Api Key By Doing /api new`)).chat()
+ new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bOr By Doing /cw setkey (key)`)).chat()
+ new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat()
+ ChatLib.chat("")
}
if (constants.data.api_key == undefined) return
diff --git a/metadata.json b/metadata.json
index 49f1375..6853f20 100644
--- a/metadata.json
+++ b/metadata.json
@@ -4,5 +4,5 @@
"entry": "index.js",
"description": "Simple Coleweight module to measure mining progression.",
"version": "1.5.0",
- "requires": ["axios", "PogData"]
+ "requires": ["axios", "PogData", "Vigilance"]
} \ No newline at end of file
diff --git a/util/constants.js b/util/constants.js
index 889ca14..d7377fd 100644
--- a/util/constants.js
+++ b/util/constants.js
@@ -6,7 +6,8 @@ let PogData = new PogObject("Coleweight", {
"y": 141,
"coleweight": 0,
"cwToggle": true,
- "first_time": true
+ "first_time": true,
+ "api_key": undefined
}, ".cw_data.json");
export default
@@ -20,7 +21,6 @@ export default
uptime: 0,
baseColeweight: 0,
stepsSinceLast: 0,
- cwGui: new Gui(),
throneValues: [],
spiralValues: [],
coleweightHr: 0,