Arrays and Dialogs
Yes, folks another tutorial by me about the magic of arrays. and some more on dialogs.
I recently discovered how helpful arrays can be and how many triggers they save you in the end.
Ok, first of all, for those who don't know, let me explain to you what arrays actually are.
Arrays are actually a mathmatical term meaning: to set or place in order (From wesbter's online). Basically, an array is a big open ches to store all your valuables. I always start my gamesyb creating just plain Player arrays, then PLayer Group Arrays (Some tirgger require you to choose a perso from a player group rather then use the Players, usually text related triggers).
Another thing you need ot kow about arrays is the Array Index. The array Index basically states, which of the 5 objects you're working with. So if we have a vriable of PlayersArray with a size of 5, your 5 indexes would be look like this
PlayersArray [1]
PlayersArray [2]
PlayersArray [3]
PlayersArray [4]
PlayersArray [5]
Let's say we have an array named Flowers with a size of 3. The we need to define what we want to set the variables in our indexes to:
Flowers[1] = Tulips
Flowers[2] = Roses
Flowers[3] = Poppy
Then, to call up Roses yuou would type Flowers[2].
Here's how I would set-up my beginning arrays. Before we do that, we need to define a few variables:
Variable Name: PlayersArray
Variable Type: Player
Array? Yes Size: However many you want, for our example we'll use 5
Variable Name: PlayerGroupsArray
Variable Type: Player Group
Array? Yes Size: Same as Players, but for us, 5
Events
Map Initlization
Conditions
None
Actions
Comment - Trigger Comment ----Set Players Array----
Set Variable - Set PlayersArray [1] = (Preset) Player 1 (Red)
Set Variable - Set PlayersArray [2] = (Preset) Player 2 (Blue)
Set Variable - Set PlayersArray [3] = (Preset) Player 3 (Teal)
Set Variable - Set PlayersArray [4] = (Preset) Player 4 (Purple)
Set Variable - Set PlayersArray [5] = (Preset) Player 5 (Yellow)
Comment - Trigger Comment ----Set Player Groups Array----
Set Variable - Set PlayerGroupsArray [1] = Player Group - Player 1 (Red)
Set Variable - Set PlayerGroupsArray [2] = Player Group - Player 2 (Blue)
Set Variable - Set PlayerGroupsArray [3] = Player Group - Player 3 (Teal)
Set Variable - Set PlayerGroupsArray [4] = Player Group - Player 4 (Purple)
Set Variable - Set PlayerGroupsArray [5] = Player Group - Player 5 (Yellow)
You can also use arrays for things such as Leaderboards, Unit Groups, Unit arrays, anything you want that the editor will allow you to.
Now, we move onto another thing people have been asking me about, dialogs.
Now, I'll be combining our knowledge or arrays to work with dialogs too, as arrays are helpful everywhere.
Let's say, a player, let's make him Player 1, types in -taunt player list and a dialog pops up giving him an optio of which of the 5 players are playing, displays there names on the dialogs, then when he clicks, sends out a message to them.
Ok, there's a couple variables we need to define before we begin here.
NOTE: We'll be sung our Player Array from the above example in this trigger.
Variable Name: TauntPlayerList
Variable Type: Dialog
Array? No
Variable Name: TauntPLayerListButtons
Variable Type: Dialog Button
Array? Yes Size: 5
First, let's define our arrays.
Events
Player - Chat Message - Player 1 (Red) types -taunt player list as An exact match
Conditions
None
Actions
Dialog - Change Title - Change Title for TauntPlayerList to Choose a player to taunt
If/Then/Else, Multiple Actions
If - Conditions
Player Slot Status Comparison - Player 2 (Blue) slot status equal to is playing
Then - Actions
Dialog - Create a dialog button titled Player - Player Name - Name of Players [2]
Set TauntPlayersListButtons [2] = (Last Created Dialog Button)
Else - Actions
Do Nothing
If/Then/Else, Multiple Actions
If - Conditions
Player Slot Status Comparison - Player 3 (Teal) slot status equal to is playing
Then - Actions
Dialog - Create a dialog button titled Player - Player Name - Name of Players [3]
Set TauntPlayersListButtons [3] = (Last Created Dialog Button)
Else - Actions
Do Nothing
If/Then/Else, Multiple Actions
If - Conditions
Player Slot Status Comparison - Player 4 (Purple) slot status equal to is playing
Then - Actions
Dialog - Create a dialog button titled Player - Player Name - Name of Players [4]
Set TauntPlayersListButtons [4] = (Last Created Dialog Button)
Else - Actions
Do Nothing
If/Then/Else, Multiple Actions
If - Conditions
Player Slot Status Comparison - Player 5 (Yellow) slot status equal to is playing
Then - Actions
Dialog - Create a dialog button titled Player - Player Name - Name of Players [5]
Set TauntPlayersListButtons [5] = (Last Created Dialog Button)
Else - Actions
Do Nothing
Dialog - Show/Hide Dialog - Show TauntPlayerList to Player 1 (Red)
Don't forget to drop trigger comments between each of the If/Then/Else statements to recognize them as you progress on your map.
Now we need to set our triggers on what to do once a button is clicked.
Events
Dialog - A Dialog Button is Clicked - A dialog button is clicked for TauntPlayerList
Conditions
Or, Multiple Conditions
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [2]
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [3]
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [4]
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [5]
Actions
If/Then/Else, Multiple actions
If-Conditions
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [2]
Then-Actions
Dialog - Show/Hide - Hide TauntPlayersList from Player 1 (Red)
Game - Text Message (Auto-Timed) - Display text message to (All Players) Player Name - Name of Player 1 (Red) says to PlayersArray [2] "You Suck Noob!"
Else-Actions
Do Nothing
If/Then/Else, Multiple actions
If-Conditions
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [3]
Then-Actions
Dialog - Show/Hide - Hide TauntPlayersList from Player 1 (Red)
Game - Text Message (Auto-Timed) - Display text message to (All Players) Player Name - Name of Player 1 (Red) says to PlayersArray [3] "You Suck Noob!"
Else-Actions
Do Nothing
If/Then/Else, Multiple actions
If-Conditions
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [4]
Then-Actions
Dialog - Show/Hide - Hide TauntPlayersList from Player 1 (Red)
Game - Text Message (Auto-Timed) - Display text message to (All Players) Player Name - Name of Player 1 (Red) says to PlayersArray [4] "You Suck Noob!"
Else-Actions
Do Nothing
If/Then/Else, Multiple actions
If-Conditions
Dialog Button Comparison - (Clicked dialog button) = TauntPlayersListButtons [5]
Then-Actions
Dialog - Show/Hide - Hide TauntPlayersList from Player 1 (Red)
Game - Text Message (Auto-Timed) - Display text message to (All Players) Player Name - Name of Player 1 (Red) says to PlayersArray [5] "You Suck Noob!"
Else-Actions
Do Nothing
Well, there ya go, ogt anyquestions, feel free to ask!
I know it should be in Tutorial/FAQ but I thought I'd leave it here for a week or so so it's easier to find.
-Frank