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.
  • The Helper The Helper:
    Happy Monday!
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Happy Friday!
    +1
  • tom_mai78101 tom_mai78101:
    Starting this upcoming Thursday, I will be in Japan for 10 days.
  • tom_mai78101 tom_mai78101:
    Thursday - Friday will be my Japan arrival flight. 9 days later, on a Sunday, will be my return departure flight.
    +2
  • The Helper The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1
  • The Helper The Helper:
    These new Chat AI programs are going to change everything everyone better Buckle the Fuck Up!
  • The Helper The Helper:
    oh and Happy Tuesday Evening! :)
    +1
  • jonas jonas:
    Im worried they'll change things for worse
  • jonas jonas:
    A lot more low quality content, a lot more half-baked stuff.
  • jonas jonas:
    If you're good enough to spot the mistakes of the answers you don't need it in the first place. If you aren't good enough, you're gonna rely on some half-correct stuff
  • The Helper The Helper:
    the earlier AI is and has been used extensively for publishing news and other content for a while now
  • jonas jonas:
    I used to be active on quora, it's now flooded with extremely similar, superficial answers that often miss the point of the question

    The Helper Discord

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top