Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Creating A Cross-Platform Leaderboard
Started by Summit Tech May 30 2014 02:49 PM

- - - - -
12 replies to this topic
leaderboard network scores
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

Hello everyone. As I am nearing the completion of my app, I have realized a need for a global, cross-patform leaderboard. For several days now I have been messing around with a free web host using PHP and mySQL. I think doing this from scratch is very difficult, and possibly not worth the time and effort. Does anyone know any better ways to make a cross-platform leaderboard for free? 

 

Thanks

Summit Tech



[TOPIC: post.html]
#2

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,598 posts
  • Jedi

Yes. Its called Coronium and its ready to go. Look at Coronium.io and the posts on this forum.

 

https://bitbucket.org/develephant/coronium-leaderboard-module/wiki/Home

 

http://coronium.org/doku.php/what_is_coronium

 

The leaderboard was demo'ed in one of the Corona Geek sessions few weeks ago. Maybe three weeks. You can see it action there. 



[TOPIC: post.html]
#3

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

This is definitely what I'm looking for. However, you must rent a server which I can't do. Hopefully there is another free option out there.

[TOPIC: post.html]
#4

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,598 posts
  • Jedi

Look at the AWS option. You can run it free for a year.



[TOPIC: post.html]
#5

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

Nice! I will DEFINITELY use this method in the future. I'm just wondering though if there are any services that don't require credit card info (AWS options needs it).

 

Thanks



[TOPIC: post.html]
#6

toga

[GLOBAL: userInfoPane.html]
toga
  • Starter
  • PipPipPip
  • 38 posts
  • Advanced Member

Hi,

try this one. Its free and easy to implement.

http://www.dreamlo.com



[TOPIC: post.html]
#7

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

That's awesome! I will be using this for my leaderboard! I was wondering if you had made a test app with this site? If so please let me know.



[TOPIC: post.html]
#8

toga

[GLOBAL: userInfoPane.html]
toga
  • Starter
  • PipPipPip
  • 38 posts
  • Advanced Member

i have tried it some time a go and it worked very well but i do not have any test code anymore. Just one hint. You have to use the corona api calls network.download and network.request for the communication with the server. The implementation was straight forward. 



[TOPIC: post.html]
#9

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

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.

[TOPIC: post.html]
#10

toga

[GLOBAL: userInfoPane.html]
toga
  • Starter
  • PipPipPip
  • 38 posts
  • Advanced Member

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 )


[TOPIC: post.html]
#11

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

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"}]}}}


[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Corona Staff
  • 8,539 posts
  • Jedi

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



[TOPIC: post.html]
#13

Summit Tech

[GLOBAL: userInfoPane.html]
Summit Tech
  • Starter
  • PipPipPipPipPipPip
  • 111 posts
  • Jedi

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


[topic_controls]
[/topic_controls]



Also tagged with one or more of these keywords: leaderboard, network, scores