SaveData Not Being Loaded Correctly

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

LM280
Monty Mole
Monty Mole
Posts: 121
Joined: Wed Jan 15, 2014 7:10 pm

SaveData Not Being Loaded Correctly

Postby LM280 » Mon Mar 23, 2020 2:26 am

It seems like SaveData is not loaded correctly when entering my episode from the SMBX main menu.

When loading a file for the first time, the value is nil and gets initialized to 0 as expected. Then if I set the value to 1 and save the game, it's still correctly set to 1 when I return to the level. If I quit the game and close the window, then open SMBX back up and open the same save file from the main menu, the value is back to nil.

Also, if I set the value to 1 and save the game, then quit to the menu and start a new save file, the value is set to 1 there too. It seems like when you open a file through the SMBX menu the new save-ext.dat isn't loaded and the game either uses the last one you were using or treats it like a new game, if you didn't previously have a file open.

Everything works exactly the way you'd expect it to if you load a file through the SMBX2 launcher. Is this just how SaveData works? You have to load the episode through the launcher?

If not, here's the relevant code. Maybe it's a mistake there.
https://hastebin.com/uzidaluhiy.cs

The intended function of the code is the store the current player/world state using tables in GameData that persist between levels, but are lost upon dying or quitting without saving. You transit between levels using pipes (not ever going to the world map) and use doors to exit to the world map and save. (That's the only time doors are used, which is why I used the door animation to trigger saving data.) When the player exits via a door to save, the contents of the GameData tables are written to the SaveData tables. When the player dies or quits without saving, the GameData is wiped, so that it gets re-initialized to the last saved value (the one in SaveData). GameData values are changed by SMBX events of the form "!Key", and upon entering a level, SMBX events of the form "!KeyEffect" are triggered if the GameData value associated with the key is ON. (There are also supposed to be multiple tables and keys in GameData and SaveData, but I just included GameData.progress/SaveData.progress and a single key for better readability at a glance.)

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: SaveData Not Being Loaded Correctly

Postby Emral » Mon Mar 23, 2020 2:38 am

Considering the legacy main menu is being phased out and not what you should be using to navigate between episodes... I don't think this'll be fixed.

LM280
Monty Mole
Monty Mole
Posts: 121
Joined: Wed Jan 15, 2014 7:10 pm

Re: SaveData Not Being Loaded Correctly

Postby LM280 » Mon Mar 23, 2020 2:47 am

Well as long as I know it isn’t because of my code, it’s fine by me. I usually use the launcher anyway so I’ll just have to add a note to the episode saying not to use the legacy menu.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari