[SOLVED] Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

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

Moderator: Userbase Moderators

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

[SOLVED] Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby dragon3025 » Wed Oct 07, 2020 7:50 pm

I'm not sure this is intended, but I have a save data variable that starts at 0. While play testing gets set to 2 in-game, and then I close the play test. There isn't any save file created, but when I re-enter the play test the variable is still set to 2. It only resets when I close the SMBX editor or use Terminate Running Process (I used it after already closing the play tester).
Last edited by dragon3025 on Thu Oct 08, 2020 11:28 pm, edited 1 time in total.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby Hoeloe » Thu Oct 08, 2020 2:09 am

I'm not sure what you're asking here? This is intended behaviour. In order to reduce loading times, the game doesn't actually close when you end a play test, it just gets dropped into the background so it can be quickly started up again for the next test. This also means the play session doesn't end, so the values for SaveData and GameData will stick around even if you don't call Misc.saveGame(). If you don't want them to, you can always use the console (hit Tab while testing) to type a line or two of Lua to quickly reset any SaveData variables you want to test out.

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

Re: Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby dragon3025 » Thu Oct 08, 2020 4:41 pm

I wasn't sure if that was intended or not. I kept getting confused to why my code change wouldn't work, but then after restarting the editor it would.

To test the console out, I tried

Code: Select all

Text.WindowDebug("Hello")
in the console and got it to give the debug message, but using

Code: Select all

globalSave.tradeitem = 0
gave me the error:
attempt to index global 'globalSave' (a nil
and the rest of the error goes off screen so I can't see it. This doesn't ever give me nil value in when running from my luna.lua, is there a way I can change that variable? Also, is there a log somewhere for my console use?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby Hoeloe » Thu Oct 08, 2020 9:44 pm

The console is not inside your lua file, so variable defined in your lua file won't exist. You'll have to access SaveData directly.

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

Re: Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby dragon3025 » Thu Oct 08, 2020 11:28 pm

Thanks, I was able to change it with

Code: Select all

SaveData["episode"].tradeitem = 0
.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: [SOLVED] Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby Hoeloe » Fri Oct 09, 2020 7:10 am

SaveData["episode"] is the same as SaveData.episode

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

Re: [SOLVED] Sava data variables persist after closing, but is reset after Terminating Running Process/Closing SMBX

Postby dragon3025 » Fri Oct 09, 2020 2:29 pm

Hoeloe wrote:
Fri Oct 09, 2020 7:10 am
SaveData["episode"] is the same as SaveData.episode
Thanks, I think I'll write it out like that from now on.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari