So Im experimenting with save files and came across something interest. For anyone new(ish) to defold you can actually access nested tables pretty easily. Im working on a game with multiple levels each with collectables etc
this is basically how the table looks
game_data ={
coins = 0,
levels = {
{score=0, collectable1=false,collectable2=false, collectable3=false},
{score=0, collectable1=false,collectable2=false, collectable3=false},
{score=0, collectable1=false,collectable2=false, collectable3=false}},
options={sound=true,music=true}
}
the way how I access the nested data is by using a function
function get_level_data(self, level)
local level_info = {
score = game_data.levels[level].score,
collectable1 = game_data.levels[level].collectable1,
collectable2 = game_data.levels[level].collectable2,
collectable3 = game_data.levels[level].collectable3
}
return level_info
end
pretty neat!