Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dummy data funxtion #5

Open
GammaGames opened this issue Jul 5, 2024 · 2 comments
Open

Add dummy data funxtion #5

GammaGames opened this issue Jul 5, 2024 · 2 comments

Comments

@GammaGames
Copy link
Collaborator

Scenic Route said on discord:

It's also useful to have the API wrapper return a stub when you're designing your UI. I use this:

scores = {
    { player = "ScenicRouteSoftware", rank = 1, value = 6000 },
    { player = "elephanteater", rank = 2, value = 5000 },
    { player = "fatnosegaming", rank = 3, value = 4000 },
    { player = "Poe", rank = 5, value = 2599 },
    { player = "kmchipman", rank = 4, value = 2800 },
    { player = "ledbetter", rank = 7, value = 2390 },
    { player = "pixelghost", rank = 6, value = 2400 },
    { player = "yessclara", rank = 8, value = 2200 },
    { player = "emre", rank = 9, value = 2199 },
    { player = "callmesteam", rank = 5293, value = 30 }
}

might be useful too include a function to check for default user strings, and include them in the dummy data

@ebeneliason
Copy link

That's a nice idea. A couple of suggested tweaks to the test data:

  • include two entries with the same rank
  • include an entry with an unreasonably long player name

Relatedly, everyone using these scoreboards has to figure out how to properly order them for display since they don't come sorted. Perhaps a helper for this would be worth including. Something like this:

function getRankedScores(scores)
	local rankedScores = {}
	for i, score in ipairs(scores) do
		rankedScores[i] = score
	end
	table.sort(rankedScores, function(a, b) return a.rank < b.rank end)
	return rankedScores
end

@GammaGames
Copy link
Collaborator Author

🤔 It might be useful to make the function something like pdScoreboards.getDummyData(ascending) where you pass a bool that defaults to sorting descending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants