Skip to content

Instantly share code, notes, and snippets.

@douira
Last active July 19, 2021 07:22
Show Gist options
  • Save douira/36b8a2aa1a624b5286fcd42eee2771ad to your computer and use it in GitHub Desktop.
Save douira/36b8a2aa1a624b5286fcd42eee2771ad to your computer and use it in GitHub Desktop.
Wynntils waypoint import converter
/*
USAGE:
Do to http://wynnwaypoints.tk/ and look for the download "For Xaero's Map".
Extract the .zip and find a text file with a name like "mw4,0,5_1.txt".
I suggest renaming it to something sane like "waypoint-data.txt".
Then run `node convert-waypoints.js waypoint-data.txt`.
This script will convert the waypoints
into a json format in a file "waypoint-data.txt_converted.json".
Take the copy the contents of this file and paste them into
the text field of this other converter: https://mitalashok.github.io/wynn-waypoints
This will output a string that you can then import into Wynntils through the clipboard.
If you don't have NodeJS installed, you can do so here: https://github.com/nvm-sh/nvm
Or run it online here: https://repl.it/@douira100/wynntils-waypoint-converter
*/
const fs = require("fs-extra")
const { toArabic } = require("roman-numerals")
//the standard data for a waypoint that is used for the properties not gotten from the data
const waypointDefaults = {
zoomNeeded: -1000,
color: "WHITE",
group: "DIAMOND"
}
//get the read location from the command line
const inFile = process.argv.slice(2).join("")
//log start
console.log(`Reading waypoint data from specified file "${inFile}"`)
//read the process the waypoint data
const waypoints = fs
//load the collected waypoints
.readFileSync(inFile)
//read file as string
.toString()
//get rid of excess white space that could cause problems
.trim()
//split into lines
.split("\n")
//discard the first line that only holds metadata
.slice(1)
//map each line to a waypoint object
.map(line => {
//split the line into pieces along the colons
const [, name, , x, y, z] = line.split(":")
//stop on invalid line
if (!z) {
return
}
//parse the tier of the chest from the name
const level = toArabic(name.match(/\[CHEST\] Tier (.+)/)[1])
//return a waypoint object with defaults and computed data
return {
//the default values
...waypointDefaults,
//construct a new name that is similar to the name the game uses,
//(I) stands for "imported" so you know which waypoints were imported and which are your own
name: `(I) Loot Chest T${level}`,
//parse the coordinates
x: parseInt(x, 10),
y: parseInt(y, 10),
z: parseInt(z, 10),
//the type depends on the level of the chest
type: `LOOTCHEST_T${level}`
}
})
//filter invalid lines
.filter(waypoint => waypoint)
//log info
console.log(`Read ${waypoints.length} waypoints. Writing output json file...`)
//construct the output file name
const outFile = `${inFile}_converted.json`
//write the output file with some extra attributes to complete the format
fs.writeJSONSync(outFile, {
waypoints,
pathWaypoints: [],
chestTiers: "TIER_3",
compassMarker: true
})
//log finished info
console.log(
"Done! Paste this into https://mitalashok.github.io/wynn-waypoints to convert to the Wynntils format."
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment