UGGHHH Data class is the bane of my existance

Need help with any SMBX game-related issues? Ask your questions here.
User avatar
Tempest
Fighter Fly
Fighter Fly
Posts: 79
Joined: Tue Jan 31, 2017 5:18 pm
Flair: not here
Contact:

UGGHHH Data class is the bane of my existance

Postby Tempest » Mon Sep 10, 2018 7:06 pm

I seriously don't know for how long I've been trying to get the Data class to work.
Basically I'm trying to make my code persist between levels (if you follow my stuff you'd probably know that wink wink) but nothing works.

This is the most recent try I've made:

Code: Select all

local encrypt = API.load("encrypt")

_G["GotPowerup"] = encrypt.Data(Data.DATA_WORLD, true)
I'm 99% sure the rest is unimportant. In a nutshell, setting something like

Code: Select all

if player.runKeyPressing then
	GotPowerup:set("phoenix",42069)
	GotPowerup:save()
end
will work fine in the level (I used Text.print() to confirm this), but when I enter another level, it is set back to nil, even without setting it to nil manually.
There's no other piece of code in the file that sets it to nil so it's just the level start messing it up
I've changed the first piece in various different ways (_G to local, adding a filename, setting it afterwards, checking several times) but it never works.
Also, every time I save it, it gets set to 1, even if I set it to another number beforehand as demonstrated in that example.

Added in 3 hours 25 minutes 58 seconds:
Oh, and trying to set it to a boolean, string or using tostring() on a number won't work.
I'm a brazilian dude who likes videogames!
Spoopy: show
http://pokemon.alexonsager.net/92/91
*insert stupid undertale reference here*
I believe in Jesus Christ as my Lord and Savior. If you do, put this in YOUR signature.
Eli Oliver (new account) wrote:hamster pipe zone?
Does anyone even know what :mrgreen: means
I Support: show
Neoteric Super Mario Bros.
viewtopic.php?t=20457
Mario and the Missing Shine Sprites
Image

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1277
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl

Re: UGGHHH Data class is the bane of my existance

Postby Hoeloe » Wed Sep 12, 2018 6:05 am

Pretty sure you have to give it a filename like this: encrypt.Data(Data.DATA_LEVEL, "encryptedData", true);

That said, if that doesn't work, I'm not sure what you're doing wrong unless in another level you're grabbing the wrong data or resetting it.

I'm glad this way of dealing with data is being scrapped in beta 4.

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8878
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: UGGHHH Data class is the bane of my existance

Postby Enjl » Wed Sep 12, 2018 6:16 am

I've gotten data class to work in 2k15 Halloween Hypnosis, 2k16 Hypnosis Redo and 2k16 December Collapse. Perhaps looking at one of these for reference will help.
Ideas are useless if you can't make them real.
Image

All my assets from packs and episodes are free to use for non-Novaverse levels and projects, as long as proper credit is given.

User avatar
Tempest
Fighter Fly
Fighter Fly
Posts: 79
Joined: Tue Jan 31, 2017 5:18 pm
Flair: not here
Contact:

Re: UGGHHH Data class is the bane of my existance

Postby Tempest » Wed Sep 12, 2018 11:19 am

Hoeloe wrote:
Wed Sep 12, 2018 6:05 am
Pretty sure you have to give it a filename like this: encrypt.Data(Data.DATA_LEVEL, "encryptedData", true);

That said, if that doesn't work, I'm not sure what you're doing wrong unless in another level you're grabbing the wrong data or resetting it.

I'm glad this way of dealing with data is being scrapped in beta 4.
Not really, I mentioned in the thread that giving it a filename doesn't work either, and I used Text.print() all the way through the level I tested. If I grab the suit, it's set to 1 (no matter if I set it beforehand, it's always 1), and it never gets set back to nil until the start of another level. But thanks anyway
Enjl wrote:
Wed Sep 12, 2018 6:16 am
I've gotten data class to work in 2k15 Halloween Hypnosis, 2k16 Hypnosis Redo and 2k16 December Collapse. Perhaps looking at one of these for reference will help.
I guess I could do that, since I didn't get much visual reference, thanks.
I'm a brazilian dude who likes videogames!
Spoopy: show
http://pokemon.alexonsager.net/92/91
*insert stupid undertale reference here*
I believe in Jesus Christ as my Lord and Savior. If you do, put this in YOUR signature.
Eli Oliver (new account) wrote:hamster pipe zone?
Does anyone even know what :mrgreen: means
I Support: show
Neoteric Super Mario Bros.
viewtopic.php?t=20457
Mario and the Missing Shine Sprites
Image


Return to “Help and Support”

Who is online

Users browsing this forum: Google [Bot] and 9 guests