Recommended Posts

Lazy-Anemic    75
13 minutes ago, watermelen671 said:

What do you mean? Are you asking about what the critter stats are? Because if that's what you're looking for...

Thanks, but I'm more interested on behind the scene things like if it's possible to edit their insulation thickness or if you can apply Dupe traits to them.

 

Share this post


Link to post
Share on other sites
watermelen671    14,408
Just now, Lazy-Anemic said:

Thanks, but I'm more interested on behind the scene things like if it's possible to edit their insulation thickness or if you can apply Dupe traits to them. 

I'm p sure it's possible to edit their insulation thickness without needing this. And while it may be possible to add Dupe traits to them, it'd just be cosmetic...without going out of your way to change a critter so that it becomes a dupe with a critter body.

Spoiler

Honestly that'd be fascinating albeit slightly terrifying.

 

  • Haha 1

Share this post


Link to post
Share on other sites
Lazy-Anemic    75
20 minutes ago, watermelen671 said:

I'm p sure it's possible to edit their insulation thickness without needing this. And while it may be possible to add Dupe traits to them, it'd just be cosmetic...

Most of the traits are going to cosmetic of course, but I want to see the effect of something like Bottomless Stomach if they really do share some of the same stats..

Then for fun see what happens when adding critters to the diet of other critters..

  • Like 1

Share this post


Link to post
Share on other sites
watermelen671    14,408
Just now, Lazy-Anemic said:

Most of the traits are going to cosmetic of course, but I want to see the effect of something like Bottomless Stomach if they really do share some of the same stats..

Then for fun see what happens when adding critters to the diet of other critters..

Wouldn't it just be easier to swap the assets of the morphs?

Share this post


Link to post
Share on other sites
Lazy-Anemic    75
4 minutes ago, watermelen671 said:

Wouldn't it just be easier to swap the assets of the morphs?

I wouldn't know, I was asking for Phred to take a look at it.

I've never went into the files directly like I did Don't Starve, I was just hoping giving them Dupe data was possible based on how stat info used to refer to them as Duplicants.

Share this post


Link to post
Share on other sites
RoboPhred    155

I haven't looked at how the creatures work yet; I actually haven't played a game to that deep of a level since the original rancher update.

You can pop your save into the vnext version and see what sort of behaviors you can find on them.  

  • Thanks 1

Share this post


Link to post
Share on other sites
asmallrabbit    43

This is a godsend for someone like me who loves to reroll dupes endlessly until im happy with them. Same effect but saves me so much time.

Share this post


Link to post
Share on other sites
Yunru    1,127

It doesn't seem to be working for me?

It fails to load the save.

130999731.sav

EDIT: It does load the sav, but then it navigates to a page that doesn't exist, making it look like the error message is related to loading the save.

Edited by Yunru

Share this post


Link to post
Share on other sites
RoboPhred    155

Yep, thats a known issue.

I was trying to get the editor to support non-editor pages, like a material property inspector.  Somewhere along the way I broke some page handling, and I havent been able to find a quick fix.

All of my effort is going into the new version right now, so I don't think I will be fixing that particular bug until the new version is ready.

Share this post


Link to post
Share on other sites

So, I was playing around with the vnext build of Duplicity a few days ago, and found the neat ability to change the mass, temp etc of items on the ground. It was under something like gameObjects > Dirt > #ID > behaviors > PrimaryElement > <object>. That was fun to play around with, have a couple kg of a resource item on the ground turn into a few tons is nice and all.

Then I get the idea to do it the other way around, and turn the multi-ton balls of Regolith lying around everywhere in the Space biome into a manageable size. Except in the last couple days since, you've updated the Duplicity vnext editor to hide the <object> property under PrimaryElement, so I can't access the mass field at all now (I think it was called "unit(s?)"), even with the new "Advanced" mode turned on.

On the other hand, there's hundreds of balls of Regolith lying around anyway, so the web editor would be extremely tedious to try and change them all. But a simple loop in a script should work perfectly!

Start with `npm install oni-save-parser`, and cloning the git repo as well, so far so good. Except the example code in your GitHub repo Readme doesn't quite run as is in a fresh environment, the package imports are named wrong / missing. I'm not really a Node guy anyway, so I fumbled my way through a bit, but ended up with this:

const fs = require("fs");
const {
  parseSaveGame,
  writeSaveGame
} = require("oni-save-parser");

const savename = "Regolith"

function loadFile(fileName) {
const fileData = fs.readFileSync(`./${fileName}.sav`);
return parseSaveGame(fileData.buffer);
}

function saveFile(fileName, save) {
const fileData = writeSaveGame(save);
fs.writeFileSync(`./${fileName}.sav`, new Uint8Array(fileData));
}

const saveData = loadFile(savename);

// Purge excess Regolith
const items = saveData.gameObjects.find(x => x.name === "Regolith");
console.log("Counting Items:")
console.log(items.length)
for (const item of items.gameObjects) {
console.log("Mass:")
console.log(item.behaviors.PrimaryElement.Units);
//item.behaviors.PrimaryElement.Units = 1 //Set to 1kg, from the usually >10000
}

//saveFile(`${savename}-tweaked`, saveData);

(As I side note, my distro included an old v4.x of Nodejs by default, which didn't understand the `const {...} = require()` syntax at all. I ended up having to install a newer version. This is partly why I'm not a Node guy in the first place, I can't deal with dependency and versioning hell. That and sorting out whether I need to look at the JS files or the TypeScript ones, or not having the tools to convert between them... >.<)

 

Now I at least got it running, and the only problem is... `items.length` is Undefined. `item.behaviors.PrimaryElement` is Undefined. I can't see into the data structure at all from the console, so I can't find the values I want to modify now.

You mentioned working on a JSON export of the parsed data, that would help. But I can't quite figure out how to get started.

 

Edit:

Later, after more blind fiddling:

So, `console.log(item.behaviors)` does give me a printout of the object, like this:

[ { name: 'KPrefabID',
    templateData: { InstanceID: 2399929 },
    extraData: undefined,
    extraRaw: undefined },
  { name: 'PrimaryElement',
    templateData:
     { ElementID: 1362238252,
       _Temperature: 614.7877807617188,
       diseaseID: [Object],
       diseaseCount: 0,
       Units: 6555.6103515625 },
    extraData: undefined,
    extraRaw: undefined },
  { name: 'Pickupable',
   ...
  },
 ...
 ]

I tried `item.behaviors["PrimaryElement"].Units`, but that didn't work. I'm just not quite sure of the Javascript syntax for nested named array elements, and which level of nesting the objects are at.

Edited by TheBrain0110
  • Like 1

Share this post


Link to post
Share on other sites

After going away for a while and letting my brain think in the background, I realized that of course, PrimaryElement isn't a named element. That part is just an index, and then there's more named pairs inside that object.

So the final value for the mass of an item is `item.behaviors[1].templateData.Units`.

The final gotcha I ran into is the way JS handles variables as references (or doesn't).

`var mass = item.behaviors[1].templateData.Units;

mass = 1;`

doesn't change anything. It has to be

`item.behaviors[1].templateData.Units = 1;`

 

Anyway, sorry about the rambling stream-of-consciousness. I started off thinking I was stuck and asking for help, then ended up just brute forcing my way to figuring it out. It's what happens when you kinda-sorta know what you're doing with programming in general, but aren't super experienced with any given language xD

 

Maybe some of these notes will be helpful to others, I dunno...

Edited by TheBrain0110

Share this post


Link to post
Share on other sites
watermelen671    14,408
4 hours ago, TheBrain0110 said:

[snip]

Still a lot better than I am. I have -10 knowledge of how to do anything.

Share this post


Link to post
Share on other sites
RoboPhred    155
On 7/10/2018 at 12:33 PM, TheBrain0110 said:

After going away for a while and letting my brain think in the background, I realized that of course, PrimaryElement isn't a named element. That part is just an index, and then there's more named pairs inside that object.

So the final value for the mass of an item is `item.behaviors[1].templateData.Units`.

The final gotcha I ran into is the way JS handles variables as references (or doesn't).

`var mass = item.behaviors[1].templateData.Units;

mass = 1;`

doesn't change anything. It has to be

`item.behaviors[1].templateData.Units = 1;`

 

Anyway, sorry about the rambling stream-of-consciousness. I started off thinking I was stuck and asking for help, then ended up just brute forcing my way to figuring it out. It's what happens when you kinda-sorta know what you're doing with programming in general, but aren't super experienced with any given language xD

 

Maybe some of these notes will be helpful to others, I dunno...

 

Sorry about breaking that area on you; I've been tweaking the save structure format to try and better support editing things without having to make dedicated editor pages for them.

It should be working again.  You will need to check the "Advanced Mode" checkbox at the top right, above the save structure tree.

 

image.thumb.png.72c588c5875e54ebd3af12ba23a70f72.png

You can try to edit the PrimaryElement too, but don't ask me what actually happens if you do.  I suspect the dups will pick up the newly specified item, but the item on the ground will remain listed as the old item due to the GameObject type, in a similar way to the geyser change issue.

The fun thing is to go and change the PrimaryElement on buildings, or even creatures!  Again I haven't tried this, but I suspect it probably will change how they interact thermally.

 

On javascript, primitives such as numbers and strings are not references, only objects and functions are.

Careful about what index you use, I usually look up the behaviors by scanning the list and seeking out the right name:

gameObject.behaviors.find(x => x.name === "PrimaryElement").templateData.Units = 42

I think you need at least Node 6 for .find to be available, otherwise you can just write your own variant to loop through and find the matching value.

 

As for batch editing, that is something on my list of eventual goals.  I had planned a type of of copy/paste macro command to let you record a change and apply it to game objects matching a filter, but that got pushed back until I can get the more basic features up to par with the 1.x version.

Share this post


Link to post
Share on other sites
9 hours ago, RoboPhred said:

 

Careful about what index you use, I usually look up the behaviors by scanning the list and seeking out the right name:

gameObject.behaviors.find(x => x.name === "PrimaryElement").templateData.Units = 42

I think you need at least Node 6 for .find to be available, otherwise you can just write your own variant to loop through and find the matching value.

Yeah, I found that out when I tried editing the temperature of buildings, and their PrimaryElement wasn't the same index as items. So I ended up using that same .find command, basing it off the one a couple lines above.

 

Here's my current script, largely based on your example code, but spruced up just a little bit:

const {
  readFileSync,
  writeFileSync
} = require("fs");
const {
  parseSaveGame,
  writeSaveGame
} = require("oni-save-parser");

// Put the name of your save file here
const savename = "Regolith"

function loadFile(fileName) {
  const fileData = readFileSync(`./${fileName}.sav`);
  return parseSaveGame(fileData.buffer);
}

function saveFile(fileName, save) {
  const fileData = writeSaveGame(save);
  writeFileSync(`./${fileName}.sav`, new Uint8Array(fileData));
  console.log("Save File Written");
}

function modifyItems(itemName, newMass, newTemp) {
  const items = saveData.gameObjects.find(x => x.name === itemName);
  for (const item of items.gameObjects) {
    var element = item.behaviors.find(x => x.name === "PrimaryElement");
    if (newMass) {element.templateData.Units = newMass;}
    if (newTemp) {element.templateData._Temperature = newTemp;}
  }
  console.log(`${itemName} Processed`)
}

function checkItems(itemName) {
  const items = saveData.gameObjects.find(x => x.name === itemName);
  for (const item of items.gameObjects) {
    var element = item.behaviors.find(x => x.name === "PrimaryElement");
    var mass = element.templateData.Units;
    var temp = element.templateData._Temperature;
    console.log(`${itemName} Mass: ${mass}`);
    console.log(`${itemName} Temp: ${temp}`);
  }
}

function printDataStructure(itemName) {
  const items = saveData.gameObjects.find(x => x.name === itemName);
  for (const item of items.gameObjects) {
    console.log(`\n${itemName}`);
    console.log(item.behaviors);
  }
}


const saveData = loadFile(savename);
console.log("Save File Parsed");

modifyItems("Regolith", 1, 10);
checkItems("Regolith");
modifyItems("BunkerTile", null, 100);
modifyItems("ExteriorWall", null, 100);
modifyItems("SolarPanel", null, 100);
modifyItems("Iron", null, 200)
modifyItems("BunkerDoor", null, 100)
modifyItems("GlassTile", null, 100)
printDataStructure("BunkerDoor");

saveFile(`${savename}-pruned`, saveData);

Source

Should work on any Node v6.x+, just stick it in a new folder, do `npm install oni-save-parser`, and copy in the save file you want to work on and put its name in `savename = `. I like to keep things simple ;)

Of course, it's also so simple that the only things it can do right now are change an object's Temperature and Mass, since I was mostly focused on wrangling the Space biome into something manageable. (and changing the Units value on buildings will have unknown effects, they all seem to be 1, not their actual mass). But it should be pretty straightforward to add other specific values if someone wanted to adapt it for their own purposes. And it only touches a value if you give it a new one, hence why I pass `null` for the mass on the buildings.

Then again if you add batch editing and macros to Duplicity, then that definitely supersedes my little script. ;)

I did add a little helper method to spit out the item.behaviors object to help find other fields worth editing, but navigating the tree in Duplicity is still the much easier way to poke around and find new things.

So despite being pretty basic, I'm still proud of some little details. It was fun :)

Share this post


Link to post
Share on other sites
he77789    86

As a maybe far feature request: when will we have world editors that gives more control than debug mode? (you know, debug templates don't work well with pipes, wires and genetic ooze.)

Share this post


Link to post
Share on other sites
RoboPhred    155

Just a heads up, the alpha is once again not compatible with the current version of the save editor.  Looks like a similar breaking change to last time.

 

On another note, vnext progresses well.  I am nearly on par with the dup editing features, plus access to the 'modifier' fields previously inaccessible (hit points, stanima, diseases, happiness, and so on).  Work on geysers will begin soon, and I will look into the possibility of doing a hard swap on game object types to change the geyser's appearance as well as output material.

 

The advanced mode of vnext continues to improve as well, although it still gets confused with certain values.  Try it out on the "Storage" behavior in particular, where you can mess with the game objects stored inside various buildings, and those being carried by dups.

  • Thanks 1

Share this post


Link to post
Share on other sites
RoboPhred    155

Support for the expressive update should be out along the next week.  I have a handle on the data changes, so barring any fundamental rewrites of how the duplicant behaviors work, it should be up and alive very soon.

I will probably bring the vNext editor live at this point, so it can get some real use and testing.  Chances are it will not have geyser editing but that isn't too far away.  Week or two if I stay focused with my free time.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
harmonium    67

Very nice job for the save editor thanks a lot !

would be so cool if you can add an option to set all stat to x, and mastery all job. Would be nice to have a mod for more range for the replicant too, for dig/build etc.

Share this post


Link to post
Share on other sites
Soulwind    247

I'm certain that I'm just doing something wrong, but the new version won't seem to let me actually edit anything.

When I bring up a dupe and go to his skills, I can see them but the entry boxes won't let me change the values so I can't actually

edit the skill levels.  Same for the aptitudes.  Traits seem to be selectable and changeable, but not anything with a value attached to it.

Share this post


Link to post
Share on other sites
RoboPhred    155
5 minutes ago, Soulwind said:

I'm certain that I'm just doing something wrong, but the new version won't seem to let me actually edit anything.

When I bring up a dupe and go to his skills, I can see them but the entry boxes won't let me change the values so I can't actually

edit the skill levels.  Same for the aptitudes.  Traits seem to be selectable and changeable, but not anything with a value attached to it.

Does the editor let you change values, but jump back to the original value once you click away?  If so, that's a sign that the editor is failing to understand the duplicant's data and cannot write to it.

If you cannot change the value at all, then it sounds like it might be a browser issue.  What OS and browser are you using?

Did you participate in the alpha before the EU release?  Is this a new save, or did it originally get created from an alpha EU or CU version?

Would you mind sending me your save file?  If this is an issue with how the editor interacts with the save, I can hunt it down pretty quickly.

Share this post


Link to post
Share on other sites
harmonium    67
34 minutes ago, RoboPhred said:

Does the editor let you change values, but jump back to the original value once you click away?  If so, that's a sign that the editor is failing to understand the duplicant's data and cannot write to it.

If you cannot change the value at all, then it sounds like it might be a browser issue.  What OS and browser are you using?

Did you participate in the alpha before the EU release?  Is this a new save, or did it originally get created from an alpha EU or CU version?

Would you mind sending me your save file?  If this is an issue with how the editor interacts with the save, I can hunt it down pretty quickly.

I can't edit anything too, i am using a fresh new save with the last update, and i have test with edge Navigator and Mozilla Firefox, i try to edit but Nothing happen, then it revert back to the initial value.

I give you my fresh save so you can see.

test 580.sav

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now