• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to create timers with dialogs?

Status
Not open for further replies.
Level 10
Joined
Jun 7, 2008
Messages
420
Creating Timers...
Dialog timers.

First of all, how to create a dialog? I'm not sure how variables work so please explain in detail.
I need a dialog to decide to either start a 15 min timer, 30 min or 45 min. Thanks. its just a one off timer.
Thanks, please post the entire trigger and variable creation process. I have never touched variables in my life.
 
Level 13
Joined
Sep 14, 2008
Messages
1,408
Well I have no worldeditor at the moment but I can try to explain you what variables are and how to use them.

1. Basics
2. Functionality
3. Variables in WE


1. Basics:

In computer programming, a variable is a keyword or phrase (identifier) that is linked to a value stored in the system's memory or an expression that can be evaluated

That just means that a variable is (lets say) like a box with a certain form.
If you have a quadrate box you can only put quadrate things in it.
And the thing which is just in the box is the "stored value".

2. Functionality:

There are variables for nearly every things but the most used types are "integers", "boolean" and "strings".
These are variables which are used in nearly every programming language.
(c, c#, c++, visual basic, java, delphi...)
World editor also uses them.

Because of that I will explain them:
Integer: An integer is simply a number. It can be 1, 2, 3 or 1000. In world editor an integer can be used to store: Ability level, hero level or a number of units.

Boolean: A simple value which can be true or false. Is used to controll things which should only happen once or to check things.
(some programming languages like sql use an integer which can be 1 or 0 for this)

String: A string is a characterband. It can be a word like "wow" or "great" but also just a number of chars like "auetcxyge"...
In world editor is it used to store things like: hero names, texts, or chat messages.

3. Variables in World editor

The world editor has a variable for every type of data used in it.
Examples are: units, doodads, destrucibles, or regions.

You can easily create them by clicking the yellow "x" in the control panel of the world editor.

Special things: There are "groups" and "arrays".

groups (unitgroups or playergroups) are variables which can store more than one thing at the same time. Image it like a room. You can put players in and out.

arrays: This is a quite easy thing which sounds difficult. An array is basicly a bunch of variables of a certain type. But they are put together.
You can access every single one by the array "index".

Example: Integer Array:

Array[] (the thing in the [] is the array "index")
Lets image the array has the size 3.
So in the array there are 3 integers.
You can access them by changing the index.

Array[0] = first integer <- IMPORTANT arrays first position is 0
Array[1] = second integer
Array[2] = third integer

So if you need for example one integer for each player you can just create an integer array.


-> Important: If you want to store something into a variable you use the trigger function: set "your variable" = yourValue. (remember the variable type must be the same as the thing you want to store in it.)



I hope that helped you to understand what a variable is... (i know it is very difficult but it is essential for using the we triggers.)


AN IMPORTANT THING:

Using variables can cause "leaks"!!!
To avoid lags caused by this leaks you have to remove them.
I think there is a tutorial about removing leaks in the tutorial section.




-> Back to your problem:

You need a dialog variable which stores your dialog.
Then you create a dialog with the trigger function: Dialog - create new (or something like that) and store it into the variable. set "yourDialogVariable" = last created dialog.

Now you need 3 button variables. (or you use a button array but I suggest using 3 because you a still a newby with this topic)

name them "button15min", "button30min" and "button45min"

then you create the 3 buttons for the dialog and store them in the variables
Trigger:
Dialog - create button for "yourButtonVariable" named 15 min.
set "button15min" = last created button
Dialog - create button for "yourButtonVariable" named 30 min
set "button30min" = last created button
Dialog - create button for "yourButtonVariable" named 45 min
set "button45min" = last created button

now you can access the dialog and the buttons through the variables.
-> important: before a dialog is visible to the players you must make it visible.

Dialog - Show "yourDialogVariable" to Player 1 (red) (the player who should decide)

Now you need a trigger with the event:

Event: Dialog button is pressed for "yourDialogVariable"
Condition: None
Action:
IF(pressed button = "button15min")
then: start timer with 15 min
IF(pressed button = "button30min")
then: start timer with 30 min
IF(pressed button = "button45min")
then: start timer with 45 min.
Dialog - Hide "yourDialogVariable" for Player 1 (Red)
 
Level 10
Joined
Jun 7, 2008
Messages
420
set "button15min" = last created button
Dialog - create button for "yourButtonVariable" named 30 min
set "button30min" = last created button
Dialog - create button for "yourButtonVariable" named 45 min
set "button45min" = last created button


Don't exactly understand this part, do I create some variables?

Here is what I did:

My variables


My create button trigger:


Also, there is no such trigger as 'create timer'. How do I create the timer?
 
Status
Not open for further replies.
Top