Voting Demo

by Complex Robot
[Share] [Zip]
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

15 downloads
Version 1.0
Date added: Aug 26 2011
1 fan
Showcasing a demo for my hub voting library. [More]
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

Advertisement

Recent Medals

Voted

Earned by The Most Interesting Man Alive
Oct 23 2012, 4:27 pm

Voted

Earned by Melkivi19
Jul 18 2012, 12:04 pm

Comments

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