Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Retreiving data using dataSaver.load — Gideros Forum

Retreiving data using dataSaver.load

simransimran Member
edited June 2014 in General questions
I am saving the game scores using dataSaver.save(), but not able to retrieve them.Here is my code

Here is what I have tried:
--in init()
self.sets = {}
self.sets[1] = 0
--in EnterFrame
if collision then
sets = dataSaver.load("|D|Scores")
for _, val in pairs(Scores) do
table.insert(self.sets, val) --value in self.sets are not getting inserted
end
table.sort(self.sets)
self.Highest = self.sets[#self.sets]
else
count = count + 1
dataSaver.save("|D|Scores", count)

end

Comments

  • HubertRonaldHubertRonald Member
    edited June 2014
    Hi @simran

    Try the next in your main.lua
    sets = dataSaver.load("|D|sets") -- loading data
    if  (not sets) then -- create "sets" if it doesn't exists
    	sets = {}
            sets.Scores = 0
            sets.GodMode = false
            sets.Goals = {}
            --
            --
            --
    	dataSaver.save("|D|sets", sets)
    end
     
    -- "sets" should be a global variable because you'll use it in different class
    For more detail check these links of our friend @ar2rsawseen

    http://www.gamasutra.com/blogs/ArtursSosins/20131129/205956/Learning_Gideros_in_10_easy_steps.php

    https://github.com/ar2rsawseen/dataSaver
  • Hi Simran.
    Don't use load and save table in OnEnterFrame!
    Try saving Score in global parameter and when you need it save the value in table by dataSaver
Sign In or Register to comment.