generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Reverse Leaderboards?

Previous Thread :: Next Thread 
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 07:33 PM
I'm going to keep bumping this until I get an answer.
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 07:55 PM
Buuuump
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 08:07 PM
Buuuump
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 08:30 PM
Buuuump
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 09:54 PM
Buuuump

Seriously. 50 views and this?
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
09 Jul 2014 11:03 PM
Buuump
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
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
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
10 Jul 2014 06:49 PM
Buuuump

I'm not giving up.. not yet...
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
10 Jul 2014 07:05 PM
Buuuump

This is just getting annoying.
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
10 Jul 2014 07:23 PM
Buuuump

How may more does this require?
Report Abuse
killer4723 is not online. killer4723
Joined: 05 Aug 2009
Total Posts: 12483
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
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
11 Jul 2014 07:26 PM
Buuuump

..again
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
11 Jul 2014 08:00 PM
Buuuump
Report Abuse
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
12 Jul 2014 01:39 PM
Buuuump

This is getting frustrating.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
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
PricyLogan is not online. PricyLogan
Joined: 26 Nov 2011
Total Posts: 2581
13 Jul 2014 10:00 PM
I should've thought of that sooner.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image