You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to find all farm tiles or planterboxes in a save file that contain mealwood. It's not super obvious to me how to traverse the game objects to find what im looking for.
I've tried this:
const { readFileSync } = require("fs");
const {
parseSaveGame,
writeSaveGame,
getBehavior,
AIAttributeLevelsBehavior
} = require("oni-save-parser");
const fs = require('fs');
function loadFile(fileName) {
const fileData = readFileSync(fileName); //`./test-data/${fileName}.sav`
return parseSaveGame(fileData.buffer);
}
function saveFile(fileName, save) {
const fileData = writeSaveGame(save);
fs.writeFileSync(fileName, new Uint8Array(fileData)); // ./test-data/${fileName}.sav
}
let fileName = 'aa';
if (process.argv[2]) {
fileName = process.argv[2];
}
const saveData = loadFile(fileName);
const stuff = saveData.gameObjects.find(e => e.name === "BasicPlantFood")
const farmTile = saveData.gameObjects.find(e => e.name === "FarmTile")
let ftn = 0 ;
for (ft of farmTile.gameObjects) {
ftn++
console.log("FarmTile:", ft)
for (be of ft.behaviors) {
console.log(ft.name, be.name)
if (be.name === "Storage") {
console.log("FarmTile.behaviors[~Storage]:", be)
}
}
break
}
console.log( JSON.stringify(farmTile))
Can you provide any guidance here?
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to find all farm tiles or planterboxes in a save file that contain mealwood. It's not super obvious to me how to traverse the game objects to find what im looking for.
I've tried this:
Can you provide any guidance here?
The text was updated successfully, but these errors were encountered: