I am trying to create a majority voting system for my game out of a total 6 players. How would I set up a majority voting system that has 4 different difficulties, and if there is an equal vote to make it pick the first one in line?
create a new dialog, add a listbox, add four list items difficulty 1 difficulty 2 etc and also and ok button. add a trigger with the event dialog item used, if it is the ok button, you check which elem of the listbox is selected, save that somehow, maybe an int array [Players], set it to 1 - 4, then check if everyone has voted yet, if so if then else w/e you wanna do now
We'll only need one trigger for the interface. We'll go with five buttons; one for each mode, and one to accept.
But first, we need to create some variables. Variables are what you use to store information and basically lots of other stuff.
Create a new global variable (global means you create it where the triggers are listed, not in a trigger). Let's name it 'Voting Dialog.' Click on the 'Type' dropdown list and select 'Dialog.'
Create another global variable. Let's call it 'Voting Button.' Change the type to dialog item. Make it arrayed (check the 'arrayed' button). Leave the dimension alone, but change the 'Size' to 4. By making it arrayed in one dimension with a size of 4, we've basically made 4 copies of one variable.
Create another global variable. Let's call it 'Voting Submit.' Change the type to dialog item. Don't make it arrayed.
Create another global variable. Let's call it 'Voting Difficulty Names.' Set the type to 'String.' Make it arrayed in one dimension (the default) with a size of four.
Create another global variable. Let's call it 'Voting Difficulty Colors.' Set the type to 'Color.' Make it arrayed in one dimension with again, a size of four.
Now we need to give some of our variables default values.
Create a new trigger. (Make sure it's before the 'Voting Dialog Trigger'). Let's call it 'Voting Data.' For the event, put 'Map Initialization.' The purpose of this trigger is to set some information for our dialog creation trigger. All the actions in this trigger are going to be 'Set Variable.'
Create the action in the trigger called 'Set Variable.' Change the variable parameter to the 'Voting Difficulty Names' variable. There should be a '[0]' listed after it. Change it to '1'. For the second part of the action after the '=,' put the name of the first difficulty, which, let's call, 'Easy.'
Copy and paste this action three times, each time adjusting the index of the variable to be one higher and changing the difficulty text to the next difficulty. You should end at 4.
Do the same thing for colors. Give each difficulty a color.
Now that we have the background information set, we can move on to creating the interface for voting.
Create a new trigger. Let's call it 'Voting Dialog.' For the event, put 'Map Initialization.'
In the actions, create the action 'Create Dialog.' Leave the modal/non-modal preset as the default 'Modal.' Let's anchor it to the top left, with a small offset. Put 50 for both the x and y offsets, and change the anchor to 'Top Left.' It'll look better narrower, so let's change the X and Y sizes to 200 by 300. The X (width) comes first.
Create the action 'Set Variable.' Set the variable (first parameter) to the variable we made called 'Voting Dialog.' After the '=,' put Last Created Dialog. We've now given ourselves a way of retrieving the dialog we created by referencing the variable we made earlier, by setting it to the dialog we just created.
Create the action 'Show/Hide Dialog.' Keep the dialog parameter in it as 'Last Created Dialog.' When dialogs are created, they are hidden by default. They have to be shown to a set of players, or one player specifically. So keep 'All Players' the same.
Now we have our dialog created. Keep in mind, the dialog is just the container for the dialog items, which are really what interface is about.
We should give our dialog a title.
Create the action 'Create Dialog Item (Label).'
The only two things we need to change are the offset and text. Set the offset to 27, 27.
Set the text to 'Difficulty.'
Now we need to create our difficulty buttons.
Create the action 'Pick Each Integer.' Set the 'Start' parameter to '1' and the 'End' parameter to '4.' This is called a loop. A loop repeats the actions listed in it until it's stopped, if ever. This loop will stop after it's fourth time running and will make the function 'Picked Integer' to the current integer it's on. In this case it will pick 1, 2, 3, and 4. Each time, the picked integer function will return the corresponding integer.
In the loop, create the action 'Create Dialog Item (Button).' Set the size to '(150, 50).' Set the anchor to 'Top.' Set the X offset to '0.' For the Y offset, click on it and select the function 'Arithmetic (Integer).' Set the operator (middle sign) to times ('*') and set the first integer parameter to the function 'Picked Integer,' and the other to 47. That spaces the buttons equally at consecutive distances on the y-axis (vertically). Click on the button text and it to the function 'Text with Color.' For the text parameter, put in the 'Convert to String' function and then click on the string parameter, where you put in the arrayed string variable we made earlier 'Voting Difficulty Names.' For the index [0], put in picked integer. For the color parameter, put in the variable we made earlier, 'Voting Difficulty Colors' and again, put picked integer into the array index ([0]). This made the buttons.
Create again the set variable action. Set the variable we made 'Voting Buttons' at the index Picked Integer to 'Last Created Dialog Item.' This wraps it up for the loop. The buttons have been made and assigned a variable.
To make the submit button:
Copy and paste the create button action use in the loop. Change the anchor to Bottom, size Y to 40, and the Y offset to a value of 23 (no need for expressions).
Create the action 'Set Variable' and set the variable we made earlier 'Voting Submit' to 'Last Created Dialog Item.'
Create the action 'Show/Hide Dialog Item' and hide the last created dialog item. We want it hidden because we don't want people clicking it before they've selected a mode.
The interface is finished!
2. Click Actions
We'll need a variable to store the currently selected difficulty of the players.
Create a new global variable and set it to type 'Integer.' Let's call it 'Selected Difficulty.' Set it to an array of one dimension of size '14.'
Now we need the trigger for when a player clicks a difficulty.
Create a new trigger. Let's call it 'Voting Select.' For the event, put 'Dialog Item is Used.' The default values don't need to be changed.
For the actions, create the action 'Pick Each Integer.' In the loop, create the action 'If Then Else.' In the if, create a condition of comparison. For the first parameter in the first part, put 'Used Dialog Item.' For the second part, put the variable we created 'Voting Button.' Set the index ('[0]') to 'Picked Integer'.
For the then part of the 'If Then Else', create the action 'Show/Hide Dialog Item.' Show the button we started off as hidden, the one we saved as the variable 'Voting Submit.'
Also create the action 'Set Variable.' Set the variable 'Selected Difficulty' at the index of the function 'Triggering Player' to the function 'Picked Integer.'
Now when a player selected a difficulty, it stores their selection, as well as shows the submit button.
To make it so when a player clicks select, the dialog disappears:
In the same trigger, create another action 'If Then Else' (not in the loop). For the condition, the same condition as the one in the loop, but instead of the variable 'Voting Button,' put 'Voting Submit.' As you'll notice, the array index field will disappear, which is fine, as there is only a single voting submit button.
For the only action in this 'If Then Else,' create 'Show/Hide Dialog.' For the show/hide preset, put 'Hide' and for the dialog parameter, put our variable 'Voting Dialog.' For the player group, put the function 'Convert Player to Player Group' and put 'Triggering Player.'
When a player clicks the submit button, the dialog will disappear.
-----
Should help. I'm working on typing properly with my fingers on the home keys, which is why I tried to write so much.
I only included two parts (UI and button action) of the alleged three. The map, if you get stuck, contains the third (difficulty outcome) part as well as explains it.
I am trying to create a majority voting system for my game out of a total 6 players. How would I set up a majority voting system that has 4 different difficulties, and if there is an equal vote to make it pick the first one in line?
SCII Profile: http://us.battle.net/sc2/en/profile/2744634/1/Drusus/
"The main reason Santa is so jolly is because he knows where all the bad girls live." - George Carlin
@NeroClaudiusDrusus: Go
create a new dialog, add a listbox, add four list items difficulty 1 difficulty 2 etc and also and ok button. add a trigger with the event dialog item used, if it is the ok button, you check which elem of the listbox is selected, save that somehow, maybe an int array [Players], set it to 1 - 4, then check if everyone has voted yet, if so if then else w/e you wanna do now
@NeroClaudiusDrusus: Go
In more detail:
You'll need these components:
-------1. Interface
We'll only need one trigger for the interface. We'll go with five buttons; one for each mode, and one to accept.
But first, we need to create some variables. Variables are what you use to store information and basically lots of other stuff.
Now we need to give some of our variables default values.
Now that we have the background information set, we can move on to creating the interface for voting.
Now we have our dialog created. Keep in mind, the dialog is just the container for the dialog items, which are really what interface is about.
We should give our dialog a title.
Now we need to create our difficulty buttons.
To make the submit button:
The interface is finished!
2. Click Actions
We'll need a variable to store the currently selected difficulty of the players.
Now we need the trigger for when a player clicks a difficulty.
Now when a player selected a difficulty, it stores their selection, as well as shows the submit button.
To make it so when a player clicks select, the dialog disappears:
When a player clicks the submit button, the dialog will disappear.
-----Should help. I'm working on typing properly with my fingers on the home keys, which is why I tried to write so much.
Thank you so much! This will surely help a lot!
SCII Profile: http://us.battle.net/sc2/en/profile/2744634/1/Drusus/
"The main reason Santa is so jolly is because he knows where all the bad girls live." - George Carlin
@NeroClaudiusDrusus: Go
I only included two parts (UI and button action) of the alleged three. The map, if you get stuck, contains the third (difficulty outcome) part as well as explains it.