30 lines
1.5 KiB
JavaScript
30 lines
1.5 KiB
JavaScript
// Run in the browser console on https://octowow.st/db/ (after its browser check has passed).
|
|
// Reads the seed plants and seed vendors and prints seeds.txt:
|
|
// "obj|objectId|zoneId|x,y x,y ..." and "npc|npcId|zoneId|x,y"
|
|
// (same coordinate units as export-trees.js). Then rebuild Data.lua with build_data.py.
|
|
// To find new seeds, search the database for "seed" and check where each one comes from.
|
|
(async () => {
|
|
const objects = [1000370, 1000371, 1000372, 2020260, 2020261, 2020262]; // pumpkin, berry, melon, grape, yam, carrot
|
|
const npcs = [51531, 51533, 9047, 9076, 12384]; // cabbage: Betty, Yrta Younghoof; spores: Jenal, Ghede, Augustus
|
|
const lines = [];
|
|
for (const [kind, ids] of [['obj', objects], ['npc', npcs]]) {
|
|
for (const id of ids) {
|
|
const page = kind === 'obj' ? 'object' : 'npc';
|
|
const html = await (await fetch('/db/?' + page + '=' + id)).text();
|
|
const locs = html.split('id="locations"')[1] || '';
|
|
const re = /myMapper\.update\(\{zone: (\d*),coords: \[(.*?)\]\}\);g_setSelectedLink/g;
|
|
let m;
|
|
while ((m = re.exec(locs))) {
|
|
if (!m[1]) continue;
|
|
const zone = +m[1], mult = zone === 0 ? 100 : 10;
|
|
const pts = [...m[2].matchAll(/\[(\d+(?:\.\d+)?),(\d+(?:\.\d+)?),/g)]
|
|
.map(p => Math.round(+p[1] * mult) + ',' + Math.round(+p[2] * mult));
|
|
if (pts.length) lines.push(kind + '|' + id + '|' + zone + '|' + pts.join(' '));
|
|
}
|
|
await new Promise(r => setTimeout(r, 250));
|
|
}
|
|
}
|
|
console.log(lines.join('\n'));
|
|
return lines.join('\n');
|
|
})();
|