ChapelR / simple-inventory

An inventory system for Twine 2/SugarCube 2.
https://inventory.twinelab.net
The Unlicense
20 stars 3 forks source link

Export/Import issue? #10

Closed HoweDaniel closed 1 year ago

HoweDaniel commented 1 year ago

Is there a known issue with exporting and importing? On my twine game the inventory systems works fine, but inventory content is not saved on export. I verified this with a button:

<<button "Serialize Game" >> <>

Doing this will empty out my inventory. The output from the Save.serialize() is logged and shows there is nothing in the inventory array. perhaps a problem with marshalling?

HoweDaniel commented 1 year ago

Tested the save using the older inventory system and that worked.

ChapelR commented 1 year ago

Strange. If it works in saves it should work in export/import. I'll need to investigate this. Thanks for the report!

HoweDaniel commented 1 year ago

for what its worth, the save to slot behavior is the same. It loses the inventory contents. Im on sugarcube 2.36.1 . My machine is MacOS/Safari also tried MacOS/Firefox.

ChapelR commented 1 year ago

It should/did work with normal saves for sure in the past, but I'll check.

HoweDaniel commented 1 year ago

Ok. let me know if I can supply you with anymore info. Unfortunately I'll soon need to revert back to the V1 simple inventory. I tested that and it still works.

ChapelR commented 1 year ago

Checking my test projects, using both normal saves and saves to disk, both work as expected, preserving the inventory data as expected.

ChapelR commented 1 year ago

If possible can you send me the compiled HTML file that is misbehaving?

HoweDaniel commented 1 year ago

Sure. the attached example demonstrates the behavior. SaveBugExample.html.zip

ChapelR commented 1 year ago

Sorry it took me so long to get back to you. The issue is not with SI3, and older SI versions will also not work with this. The game state is only updated on passage navigation, and this has always been the case. Changes to in-engine variables after the last passage nav and before the next will never be (and have never been) reflected in saved games or serialized moments, it will revert to the state things were in the last time navigation occurred. Again, this is just a hard limitation of the engine, nothing unique to this library.

By picking up the item, navigating to a the same passage via the console, and then saving I was able to get the inventory state to update and work as expected in the example file you sent over.

HoweDaniel commented 1 year ago

Thank you for the update. Is there a way to force the l logic in the navigation prior to the save? Re-navigate to the room your in via javascript? maybe something more granular? I would greatly appreciate suggestions on ways to get around this. thanks.

ChapelR commented 1 year ago

Even if you play a big AAA video game, you'll find that most of the time, when you save and load, it'll put you back to a checkpoint, whether that's leaving or entering a room, just after or before a cutcsene, or the start or end of the most recent combat encounter. So my first question would be, how much actual progress so players stand to lose by being loaded in at the last passage navigation? If it's a small amount I wouldn't bother.

If you think the amount of progress players would lose would be significant, I would ask how far along you are and if it's possible to change your game to feature more consistent passage navigations, as they are important to the engine.

If neither of those works, you can use a save event to manually update the variable store (or just the inventory) before saving, but I think this is worth avoiding if at all possible.