|
| 09 Jul 2014 07:25 PM |
So, I used the "Ordered data store" article from the ROBLOX wiki, and I figured out how to make it work. But is there any way to reverse the order? What I mean is, instead of the highest-scoring person being first, it would be the lowest-scoring first. So, the person with the lowest score gets first place on the leaderboard.
The reason I want this is I'm trying to show the fastest times for a person to complete a level, and I don't want the person with the worst score.
If it helps, here's my working script. All I need is for the lowest scores to go first on it, as I previously stated.
local ods = game:GetService("DataStoreService"):GetOrderedDataStore("LevelTime")
function updateBoard(board, data) for k,v in pairs(data) do local pos = k local name = v.key local score = v.value local nametextbox = board.SurfaceGui:FindFirstChild("Name" .. pos) nametextbox.Text = name local scoretextbox = board.SurfaceGui:FindFirstChild("Score" .. pos) scoretextbox.Text = score end end
while true do local pages = ods:GetSortedAsync(false, 5) local data = pages:GetCurrentPage() updateBoard(game.Workspace.Top5ScoreBoard, data) if not pages.IsFinished then pages:AdvanceToNextPageAsync() data = pages:GetCurrentPage() updateBoard(game.Workspace.Next5ScoreBoard, data) end wait(.1) end |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 07:33 PM |
| I'm going to keep bumping this until I get an answer. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 09 Jul 2014 09:54 PM |
Buuuump
Seriously. 50 views and this? |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Jul 2014 11:22 PM |
Not sure, I never use DS. Maybe this will help:
local reverse_table=function(tab) for i=1,#tab do tab[i]=tab[(#tab+1)-i) end end
This should reverse a table I think.
local tab={1,2,3,4} reverse_table(tab) |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 09:40 AM |
Not sure, I never use DS. Maybe this will help:
local reverse_table=function(tab) for i=1,#tab do tab[i]=tab[(#tab+1)-i)] end end
local tab={1,2,3,4} reverse_table(tab) print(table.concat(tab,', ')) |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 06:23 PM |
I haven't seen a single person on the forums with any idea what they're talking about when it comes to DataStore.
You're not alone. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 06:49 PM |
Buuuump
I'm not giving up.. not yet... |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 07:05 PM |
Buuuump
This is just getting annoying. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 07:23 PM |
Buuuump
How may more does this require? |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 07:25 PM |
New to scripting but here is a bump, mind looking at this script real quickly http://www.roblox.com/Forum/ShowPost.aspx?PostID=139929365 |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 09:44 PM |
I just read the tutorial for ordered datastore. If I'm right, it returns a table. Just change the current page to the last page or iterate through it and check when isFinished is fired. Then, use my function to reverse it, since it returns a table.
Remember, I read the tutorial once. I've probably got a lot of things wrong. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 06:38 PM |
| How am I supposed to add that to the script? I tried it in 3 ways and neither worked. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 12 Jul 2014 01:39 PM |
Buuuump
This is getting frustrating. |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2014 08:19 PM |
local ods = game:GetService("DataStoreService"):GetOrderedDataStore("LevelTime")
local reverse=function(data) for i=1,#data do data[i]=data[(#data+1)-i] end return data end
function updateBoard(board, data) local realdata=reverse(data) for k,v in pairs(realdata)do local pos = k local name = v.key local score = v.value local nametextbox = board.SurfaceGui:FindFirstChild("Name" .. pos) nametextbox.Text = name local scoretextbox = board.SurfaceGui:FindFirstChild("Score" .. pos) scoretextbox.Text = score end end
while true do local pages = ods:GetSortedAsync(false, 5) local data = pages:GetCurrentPage() updateBoard(game.Workspace.Top5ScoreBoard, data) if not pages.IsFinished then pages:AdvanceToNextPageAsync() data = pages:GetCurrentPage() updateBoard(game.Workspace.Next5ScoreBoard, data) end wait(.1) end
|
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 09:59 PM |
Since that didn't exactly work.. I'll save the numbers as negatives and show the positive form on the scoreboard. That should work. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 10:00 PM |
| I should've thought of that sooner. |
|
|
| Report Abuse |
|
|