Thanks. I got it work to the point where every time I use my function, I save the json data to a file. I’m having trouble loading the scores and then setting them equal to variables.
try something like that.
local path = system.pathForFile( “score”… “.json”, system.DocumentsDirectory )
local file = io.open( path, “r” )
if not file then
return
end
globalScores = json.decode( file:read( “*a” ) )
io.close( file )
Yup. I now have a json file created but there is a problem with the json’s format. It is quite strange. All of the data is in a sub-sub-sub family. Also the names and scores are in a seemingly unaccessable family. I want to take the first 100 names and scores and make a list of them. Still having some trouble.
Edit: here is the json file
{"dreamlo":{"leaderboard":{"entry":[{"name":"SummitTech","score":"55"},{"name":"Brengor","score":"43"},{"name":"DrClueless","score":"39"},{"name":"Duplon","score":"31"},{"name":"Skygoma","score":"23"}]}}}
If it helps, you can put some newlines in there to help you understand the structure a bit better:
{"dreamlo": {"leaderboard": {"entry":[ {"name":"SummitTech","score":"55"}, {"name":"Brengor","score":"43"}, {"name":"DrClueless","score":"39"}, {"name":"Duplon","score":"31"}, {"name":"Skygoma","score":"23"}] } } }
When this gets json.decode()'ed into a Lua table you have (lets call the table “t”:
t.dreamlo.leaderboard.entry[1].name
t.dreamlo.leaderboard.entry[1].score
t.dreamlo.leaderboard.entry[2].name
t.dreamlo.leaderboard.entry[2].score
t.dreamlo.leaderboard.entry[3].name
t.dreamlo.leaderboard.entry[3].score
etc.
Here is a little sample to show you:
local json = require("json") local t = json.decode([[{"dreamlo": {"leaderboard": {"entry":[ {"name":"SummitTech","score":"55"}, {"name":"Brengor","score":"43"}, {"name":"DrClueless","score":"39"}, {"name":"Duplon","score":"31"}, {"name":"Skygoma","score":"23"}] } } } ]] ) print(t.dreamlo.leaderboard.entry[1].name) print(t.dreamlo.leaderboard.entry[1].score) print(t.dreamlo.leaderboard.entry[2].name) print(t.dreamlo.leaderboard.entry[2].score) print(t.dreamlo.leaderboard.entry[3].name) print(t.dreamlo.leaderboard.entry[3].score)
Rob
Thank you so much Rob! You have no idea how helpful your post was! I will try messing with my code in a bit. I’ll let everyone know if things workout.
Thanks again
I already have a number of AWS servers running Ubuntu, with PHP, MySQL, MongoDB, and some with nodejs. Are there instructions on how I can install coronium on an existing EC2 instance?
I already have a number of AWS servers running Ubuntu, with PHP, MySQL, MongoDB, and some with nodejs. Are there instructions on how I can install coronium on an existing EC2 instance?