Data Class

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
fern
Swooper
Swooper
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Data Class

Postby fern » Tue Dec 12, 2017 12:14 am

Is it possible to load data from a different script? I want to use data from my lunaworld in my lunadll's.

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Data Class

Postby The0x539 » Tue Dec 12, 2017 12:56 am

1) make a dummy API that just returns an empty table, load it shared (as API.load does by default if memory serves), and use it as a table
or
2) use global variables, in a responsible fashion

fern
Swooper
Swooper
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Data Class

Postby fern » Tue Dec 12, 2017 2:22 am

The0x539 wrote:1) make a dummy API that just returns an empty table, load it shared (as API.load does by default if memory serves), and use it as a table
or
2) use global variables, in a responsible fashion
Thanks! I'll try the first option tomorrow since I mostly get errors when I try messing with global variables.

fern
Swooper
Swooper
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Data Class

Postby fern » Tue Dec 12, 2017 3:58 pm

The0x539 wrote:1) make a dummy API that just returns an empty table, load it shared (as API.load does by default if memory serves), and use it as a table
or
2) use global variables, in a responsible fashion
Hey, I have two questions about the data class:
1. Where is this data stored? Is it inside the actual save files?
I ask this because sometimes, it seems like data stays in the slot even after I delete the save file, and it creates problems when testing.

2. When setting new values should they be set before your code, or inside onStart()? Where should I write this?

Code: Select all

if levelData:get("introDone") == nil then
	levelData:set("introDone", 0)
	levelData:save()
end
EDIT: The data is now permanently there after deleting my saves. How do I get rid of it?

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Data Class

Postby The0x539 » Tue Dec 12, 2017 8:20 pm

fern wrote:
The0x539 wrote:1) make a dummy API that just returns an empty table, load it shared (as API.load does by default if memory serves), and use it as a table
or
2) use global variables, in a responsible fashion
Hey, I have two questions about the data class:
1. Where is this data stored? Is it inside the actual save files?
I ask this because sometimes, it seems like data stays in the slot even after I delete the save file, and it creates problems when testing.

2. When setting new values should they be set before your code, or inside onStart()? Where should I write this?

Code: Select all

if levelData:get("introDone") == nil then
	levelData:set("introDone", 0)
	levelData:save()
end
EDIT: The data is now permanently there after deleting my saves. How do I get rid of it?
yeah Data class stuff is stored in a file, it should be in the same place as the .sav but a separate file. not to mention global and level data. Are you sure this is what you want?

fern
Swooper
Swooper
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Data Class

Postby fern » Tue Dec 12, 2017 10:07 pm

The0x539 wrote:
fern wrote:
The0x539 wrote:1) make a dummy API that just returns an empty table, load it shared (as API.load does by default if memory serves), and use it as a table
or
2) use global variables, in a responsible fashion
Hey, I have two questions about the data class:
1. Where is this data stored? Is it inside the actual save files?
I ask this because sometimes, it seems like data stays in the slot even after I delete the save file, and it creates problems when testing.

2. When setting new values should they be set before your code, or inside onStart()? Where should I write this?

Code: Select all

if levelData:get("introDone") == nil then
	levelData:set("introDone", 0)
	levelData:save()
end
EDIT: The data is now permanently there after deleting my saves. How do I get rid of it?
yeah Data class stuff is stored in a file, it should be in the same place as the .sav but a separate file. not to mention global and level data. Are you sure this is what you want?
Yeah, I couldn't find it and realized that I've been using global data instead of world data the whole time. Is it bad to delete it? I delete it to test because shouldn't it be empty anyways when you start a new game?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari