hi guys,
Sorry if this already asked before. Im creating non commercial children educational game on android. I'm trying to save player progress in a form of star-score much like angry birds. Basically on each level icon I put stars indicating how well the player went through that level.
Its okay when the app is still playing. But whenever I exit the app. reset (or clear ram). When I get back to the app, all of those progress are gone. I've tried both table.save and datasaver with no success. On device player testing failings, also I try converting them to apk file and make sure the permission to external storage available, still failing. whatever I tried it just not working. I'm a newbie in gideros and lua, so perhaps its just a silly mistake or simple step that I missed?
here are my codes (I dont understand how to enclosed it in script container in this forum text editor, sorry):
-- in main.lua
gameSkor = {}
gameSkor.huruf001 = dataSaver.loadValue("gameSkorHuruf001")
if(not gameSkor.huruf001) then --if not exist yet
gameSkor.huruf001 = 0
end
gameSkor.huruf002 = dataSaver.loadValue("gameSkorHuruf002")
if(not gameSkor.huruf002) then --if not exist yet
gameSkor.huruf002 = 0
end
-- .. etc
function updateScoreFile(skor) -- the function will be called from other file
if curGameLevel == gameHuruf_level_001 then
gameSkor.huruf001 = skor
dataSaver.saveValue("gameSkorHuruf001", gameSkor.huruf001)
elseif curGameLevel == gameHuruf_level_002 then
gameSkor.huruf002 = skor
dataSaver.saveValue("gameSkorHuruf002", gameSkor.huruf002)
end
end
kind regrads,
Comments
What you need to do is to save and read everything from Documents directory like this:
More info:
http://docs.giderosmobile.com/file_system.html
I was following the script from artleeapp at:
http://www.giderosmobile.com/forum/discussion/3558/using-data-files
how can he manage not using |D| ?
Is testing on device using gideros player allow us to save on local storage?
Or should we build .apk file first to test it?
regards,
And no you don't need to build .apk for that and can test it on any Gideros Player (device or desktop)
I tried on device, desktop even on android apk build.
I will try to create more simpler example to undestrand the problem
it should actually work without |D| because of loadValue and saveValue methods, already internally use on single file inside Documents directory.
If you would be using load and save to store in separate files, then you would need to specify directories.
In your case it seems that something overwrites the values or clears those files on each run.
You could try opening Documents directory on your OS file system and see if everything you wanted to save is actually there.
http://members.giderosmobile.com/knowledgebase.php?action=displayarticle&id=57
huruf003 0
huruf002 0
huruf007 0
huruf009 0
huruf001 0
huruf005 0
huruf008 0
huruf010 0
..
which correct, but when I stop and restart the app, print will spit out strange codes:
(screenshot attached)
Here is a quick fix discussed in this thread:
http://www.giderosmobile.com/forum/discussion/3038/problem-with-json-decode-and-char-encoding/p1
I dont use huruf001 instead I use hurufSatu etc (its indonesian). Basically not using any numbers in a key name.
So its a json problem, I see. I also fix the json class with the quick fix on that discussion just in case.
Thank you for your support arthur!!