JAVA (Just another Voting Asset)

Siretu

Starcraft 2 Editor Moderator
Staff member
Reaction score
293
For previous maps I just searched SC2mapster for a voting system instead of writing my own but I felt all the ones I found lacked some key features. So for my new map I decided to write a very customizable voting system with all the features I feel are needed.

You specify the amount of things to vote for, the amount of choices each thing you vote for has(so you can vote for one thing that has two options and one that has three), you also specify the names of the different things, possibly the timeout timer.

You can also specify some constants on the dialog but they come with some decent values.

One of the things I like about it is that it automatically scales up your dialog depending on the amount of buttons you have so you don't have to specify the exact width and height.



The colored line shows the different constants you can change to change the dialog's size.

Blue is Vote Edge Offset.
Red is Choice Gap
Yellow is Vote gap(basically the distance between the different things you vote for)
Pink is Choice Button Width
White is Choice Button height.

Features:
  • Automatically scales width and height to fit your settings.
  • Allows you to vote for several different things with different amount of choices.
  • Timeout timer
  • Allows you to change your votes around.

Tutorial:

Basically, there are 2 parts to edit.

* The appearence of the dialog box
* The polls and all the button info.

Dialog Appearence:

The library comes with some default values that work fine. If you do want to edit it, the variables you need to edit are: Vote edge offset, choice gap, vote gap, choice button width and choice button height. Use the picture above for reference on how to use them.

Poll info:

There's a couple of places to modify to fix this part.

First place is the Init Vote Options function. It comes with some default stuff(that you probably want to change) but it should help you to get started.

Basically:
Vote Options.Polls = the amount of polls(things to vote for)
Vote Options.Choices[x] = the amount of choices for the Xth poll.
Vote Option.Choice Names[x][y] = The name of the Yth choice on the Xth poll
Vote Options.Poll names[x] = Name of the Xth poll.

To modify the things that happens when a choice is voted for, go to Apply vote results. For each poll you need a switch and for each choice you need a case in the switch. You should be able to figure it out from the defaults in there.

You might also want to modify the Timeout time. That is the time you have to vote before the vote expires.


Download: View attachment JAVA.SC2Lib
 

Sevion

The DIY Ninja
Reaction score
424
Pretty cool. If you released this I would use it whenever I needed a voting system <3
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
is this system capable of getting an average number out of the votes? ie: someone votes for 0 and someone votes for 150 and it returns 75
 

Siretu

Starcraft 2 Editor Moderator
Staff member
Reaction score
293
No, but it should be relatively easy to implement.

Edit:

I haven't tried this out but the apparent solution would be to modify the "Voting Done" function and change:

Trigger:
  • General - For each integer a from 0 to (Vote Options.Polls - 1) with increment 1, do (Actions)
    • Actions
      • Variable - Set max = 0
      • General - Pick each integer from 0 to 9, and do (Actions)
        • Actions
          • Variable - Set Total votes[(Picked integer)] = 0
      • Player Group - For each player b in (Active Players) do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • Player Vote[a]<b> != -1
            • Then
              • Variable - Modify Total votes[Player Vote[a]<b>]: + 1
            • Else
      • General - For each integer b from 0 to Vote Options.Choices[a] with increment 1, do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • max &lt; Total votes<b>
            • Then
              • Variable - Set max = Total votes<b>
              • Variable - Set max index = b
            • Else
      • Variable - Set Player results[a] = max index
    • </b></b></b></b>


to
Trigger:
  • General - For each integer a from 0 to (Vote Options.Polls - 1) with increment 1, do (Actions)
    • Actions
      • Variable - Set total = 0
      • General - Pick each integer from 0 to 9, and do (Actions)
        • Actions
          • Variable - Set Total votes[(Picked integer)] = 0
      • Player Group - For each player b in (Active Players) do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • Player Vote[a]<b> != -1
            • Then
              • Variable - Modify total: + (Integer(Vote Options.Choice Names[a]<b>))
            • Else
      • Variable - Set Player results[a] = (total / (Number of players in (Active Players)))
    • </b></b>
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I have a bunch of community service I have to do, and I have a feeling there will be a lot of snow shoveling involved now
  • The Helper The Helper:
    don't know why people choose to live in that kind of weather :)
  • Varine Varine:
    Well
  • Varine Varine:
    My job is here
  • Varine Varine:
    I was born here man I didn't choose shit
  • Varine Varine:
    And also, I keep moving away and it doesn't get any better. I moved to San Antonio and shit froze there AND we had blackouts
  • tom_mai78101 tom_mai78101:
    I'm back, suffering from severe jet lag.
  • The Helper The Helper:
    Cold is following your ass around Varine - I just dont think I could handle a snowy winter.
  • The Helper The Helper:
    Welcome Back Tom!
  • The Helper The Helper:
    I hear that taking a Melatonin around your normal bedtime can really fix jet lag
  • tom_mai78101 tom_mai78101:
    Yeah, I also heard about that as well. I think I'm good. I'm just lucky it's the weekend so I have some time to readjust.
    +1
  • Varine Varine:
    It was a fucking blizzard today, shoveling was an effort in futility.
  • Varine Varine:
    Melatonin gives me nightmares
  • Varine Varine:
    They had me shoveling out the parking lot for the jail. Fucking pointless, they need a blow.
  • Varine Varine:
    Well they gave me a snow blower but it was too wet to do much with with other than compact everything. Oh well, the cop cars can get into there now when they arrest people I guess
    +1
  • The Helper The Helper:
    I shit you not we are Number one on Google for Banana Bread Recipe
  • jonas jonas:
    xD
    +1
  • The Helper The Helper:
    Need Web Design Contractor that knows Word Press, Woocommerce and Elementor to help with the company that sponsors this site
  • The Helper The Helper:
  • The Helper The Helper:
    I am going to be AFK most of this weekend has I have a friend coming into town for his company christmas party and I am going to be busy with that this weekend.
    +1
  • The Helper The Helper:
    541 Active Users and this number has been pretty steady give or take some. The bots are hammering us.
  • The Helper The Helper:
    I have been posting a bunch of recipes and Google is loving them. I mean OK my shit is good but how does google know LOL!

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top