Voting Demo

by Complex Robot
Showcasing a demo for my hub voting library. [More]
To download this game for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://ComplexRobot.VotingDemo##version=0

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://ComplexRobot.VotingDemo##version=0

17 downloads
Version 1.0
Date added: Aug 25 2011
Last updated: Aug 26 2011
2 fans
This shows how players can vote using the library.
All of the voting information is saved in the standings.

Here is the code in the project (copy-paste-able):
world
name = "Voting Demo - Your Favorite Melee Weapon"
hub = "ComplexRobot.VotingDemo"
hub_password = /* password removed */

mob
Stat()
statpanel("Poll")
stat(POLL_QUESTION, "")
stat("------------------", "")
var/list/votes = GetVotes()
var/list/percs = Percentages(votes)
for (var/X in votes)
stat(X, "[percs[X]]% ([votes[X]])")

proc
GetVotes()
var/params = world.GetScores(, POLL_SCORE_NAME)
if (isnull(params))
return list()
params = params2list(params)
var/val
for (var/X in params)
val = params2list(world.GetScores(X, POLL_SCORE_NAME))
params[X] = text2num(val[POLL_SCORE_NAME])
return params
Percentages(list/L)
var/total = 0
var/list/result = new
for (var/X in L)
total += L[X]
for (var/X in L)
result[X] = round(100 * L[X] / (total || 1), 1)
return result

Recent Medals

Voted

Earned by Deathmonk
Jan 5 2014, 9:08 am

Voted

Earned by Melkivi19
Jul 18 2012, 9:04 am

Comments

Complex Robot: (Aug 27 2011, 6:29 am)
But, there is a cancel button.
Lord Runa: (Aug 27 2011, 12:32 am)
A way to cancel without voting would be nice. Like, if you misclicked or something.