Page 1 of 1

Data Class

Posted: Tue Dec 12, 2017 12:14 am
by fern
Is it possible to load data from a different script? I want to use data from my lunaworld in my lunadll's.

Re: Data Class

Posted: Tue Dec 12, 2017 12:56 am
by The0x539
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

Re: Data Class

Posted: Tue Dec 12, 2017 2:22 am
by fern
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.

Re: Data Class

Posted: Tue Dec 12, 2017 3:58 pm
by fern
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?

Re: Data Class

Posted: Tue Dec 12, 2017 8:20 pm
by The0x539
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?

Re: Data Class

Posted: Tue Dec 12, 2017 10:07 pm
by fern
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?