diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-18 09:22:18 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-18 09:22:18 +0800 |
commit | 2020b4e189fac02c1b5809522d25bc836d857930 (patch) | |
tree | be415643e9357e40ecf46e6319c8ed0c7b9287b6 | |
parent | 91ce2e47013f18e85a08bc9d368130673b67f6ea (diff) | |
download | SoopyV2-2020b4e189fac02c1b5809522d25bc836d857930.tar.gz SoopyV2-2020b4e189fac02c1b5809522d25bc836d857930.tar.bz2 SoopyV2-2020b4e189fac02c1b5809522d25bc836d857930.zip |
+ convert command for ordered waypoints
-rw-r--r-- | babel-import-promise/babel-import-promise.mjs | 9 | ||||
-rw-r--r-- | src/features/waypoints/index.js | 22 | ||||
-rw-r--r-- | src/utils/networkUtils.js | 7 |
3 files changed, 24 insertions, 14 deletions
diff --git a/babel-import-promise/babel-import-promise.mjs b/babel-import-promise/babel-import-promise.mjs index 24cc28f..8d96eab 100644 --- a/babel-import-promise/babel-import-promise.mjs +++ b/babel-import-promise/babel-import-promise.mjs @@ -30,16 +30,17 @@ export default function ({ types: t }) { const MyVisitor2 = { Identifier(path) { if (path.node.name === "fetch") { - shouldAdd = true + shouldAdd2 = true } } }; + path.traverse(MyVisitor2) - if (shouldAdd2) { - let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 3 + if (shouldAdd2 && !state.filename.includes("networkUtils")) { + let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 2 const identifier = t.identifier('fetch'); const importDefaultSpecifier = t.importDefaultSpecifier(identifier); - const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'utils/networkUtils')); + const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'SoopyV2/utils/networkUtils')); path.unshiftContainer('body', importDeclaration); } } diff --git a/src/features/waypoints/index.js b/src/features/waypoints/index.js index 9d98ef2..9188ddf 100644 --- a/src/features/waypoints/index.js +++ b/src/features/waypoints/index.js @@ -138,6 +138,21 @@ class Waypoints extends Feature { console.log(e.stack) } }) + this.registerCommand("converttoorder", () => { + try { + this.userWaypointsArr.forEach(w => { + let k = w.options.name + this.orderedWaypoints.set(parseInt(k), [w.x, w.y, w.z, k]) + }) + this.currentOrderedWaypointIndex = 0 + + if (this.showInfoInChat.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + "Converted into order. You might need to do /clearwaypoints to see (WARNING WILL CLEAR NORMAL WAYPOINTS)!") + } catch (e) { + if (this.showInfoInChat.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + "Error loading!") + console.log(JSON.stringify(e, undefined, 2)) + console.log(e.stack) + } + }) this.registerCommand("setorderwaypointindex", (ind) => { this.currentOrderedWaypointIndex = parseInt(ind) if (this.showInfoInChat.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + "Set index to " + ind + "!") @@ -167,24 +182,21 @@ class Waypoints extends Feature { let distanceTo1 = Infinity if (currentWaypoint) { distanceTo1 = Math.hypot(Player.getX() - currentWaypoint[0], Player.getY() - currentWaypoint[1], Player.getZ() - currentWaypoint[2]) - drawCoolWaypoint(currentWaypoint[0], currentWaypoint[1], currentWaypoint[2], 0, 255, 0, { name: this.currentOrderedWaypointIndex.toString() }) + drawCoolWaypoint(currentWaypoint[0], currentWaypoint[1], currentWaypoint[2], 0, 255, 0, { name: currentWaypoint[3] }) } let nextWaypoint = this.orderedWaypoints.get(this.currentOrderedWaypointIndex + 1) - let name = (this.currentOrderedWaypointIndex + 1).toString() if (!nextWaypoint) { if (this.orderedWaypoints.get(0)) { nextWaypoint = this.orderedWaypoints.get(0) - name = "0" } else if (this.orderedWaypoints.get(1)) { nextWaypoint = this.orderedWaypoints.get(1) - name = "1" } } let distanceTo2 = Infinity if (nextWaypoint) { distanceTo2 = Math.hypot(Player.getX() - nextWaypoint[0], Player.getY() - nextWaypoint[1], Player.getZ() - nextWaypoint[2]) - drawCoolWaypoint(nextWaypoint[0], nextWaypoint[1], nextWaypoint[2], 0, 255, 0, { name }) + drawCoolWaypoint(nextWaypoint[0], nextWaypoint[1], nextWaypoint[2], 0, 255, 0, { name: nextWaypoint[3] }) } if (this.lastCloser === this.currentOrderedWaypointIndex && distanceTo1 > distanceTo2 && distanceTo2 < 15) { diff --git a/src/utils/networkUtils.js b/src/utils/networkUtils.js index ca3270a..41d27e5 100644 --- a/src/utils/networkUtils.js +++ b/src/utils/networkUtils.js @@ -176,10 +176,7 @@ if (!global.networkUtilsThingSoopyPromise) { } }) - global.networkUtilsThingSoopyPromise = { - getUrlContent: getUrlContent, - fetch: fetch - } + global.networkUtilsThingSoopyPromise = fetch } -module.exports = global.networkUtilsThingSoopyPromise +export default global.networkUtilsThingSoopyPromise |