Data Class
Posted: 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.
Thanks! I'll try the first option tomorrow since I mostly get errors when I try messing with global variables.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: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
Code: Select all
if levelData:get("introDone") == nil then
levelData:set("introDone", 0)
levelData:save()
end
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 wrote:Hey, I have two questions about the data class: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
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?EDIT: The data is now permanently there after deleting my saves. How do I get rid of it?Code: Select all
if levelData:get("introDone") == nil then levelData:set("introDone", 0) levelData:save() end
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?The0x539 wrote: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 wrote:Hey, I have two questions about the data class: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
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?EDIT: The data is now permanently there after deleting my saves. How do I get rid of it?Code: Select all
if levelData:get("introDone") == nil then levelData:set("introDone", 0) levelData:save() end