HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Easiest way to make a Yes/No dialogue box

02-07-2004, 03:40 AM#1
Huh
Ok basically I am trying to make a box that will popup when a player clicks a hero, asking if they want to select the hero. There should be a yes button and a no button. If they click yes they get the hero and it spawns in a region, if no, the box disappears and they can choose another. JUST HOW could i go about doing this? I thought it might be a type of multiboard, and use dialogue buttons but I'm not really sure. Would be great if someone knows of an unprotected map using something just like this that they could link me to :). Thanks guys.

-Huh
02-07-2004, 04:44 AM#2
Huh
I found the tutorial in tutorial section for creating dialogs and it helped a little but my big problem now is this. At the moment i have a trigger that says basically event- player selects a unit, condition- OR: any condition is true (lists each hero as a condition), actions (spawns the unit in new area for the player).

I managed to make triggers to create the Yes/No dialog menu. Problem is that (i think) in order to make actions respond to when a button is clicked, i need the event to be Dialog- a dialog button is clicked for *** (where *** is name of dialog variable). In my original trigger the event is player selects a unit. In the new triggers, i use the event- player selects a unit to show the dialog menu thats created in map init.
In my original trigger, all the actions were based on the triggering player and unit in the event. Copying those actions to the new trigger with event Dialog- a dialog button is clicked wont work because the actions are dependent on the event (which in this case doesnt have a triggering player or unit).

Sorry if this is kind of hard to read. Its late and im getting tired. Just wanted to get this to work before i go to bed. Thanks guys.

-Huh
02-07-2004, 05:05 AM#3
Dalten
Here's how I do it. I was a little confused at what all exactly you had done, but i'm going to assume your missing the part of setting up proper variables.

You'll need one "Dialog" variable and then one "Dialog Button" Variable for every option you want to display on the dialog list.

Hope this helps.
02-07-2004, 05:23 AM#4
Huh
Well, i have the variables setup right I believe. Problem I have atm is that I cant seem to make it so when the player clicks the yes button for it to spawn a unit for them. I can make the unit spawn fine based off the player selects a unit event, but not with the dialog- a button is clicked event. Sorry im terrible at explaining this.

Ever play Tides of Blood? A couple versions ago they had their hero selection setup so if you clicked a hero at the beginning, it asked if you want that hero and gave a yes and no button. If you clicked yes you got that hero and if you clicked no you got to pick another one. Thats almost EXACTLY what im trying to do, just cant figure it out.. and sadly ToB is protected so i cant open it to get a clue.
02-07-2004, 05:34 AM#5
Dalten
Sounds like your doing it right then so far. I'd do it like this:

1) Detect the hero is selected, then run the variable set ups and Show the dialog box.

2) Create a trigger that'll detect what button they pressed(LIke the 2nd one in the pic above). Notice I used several "IF THEN ELSE / MULTIPLE FUNCTIONS" Triggers, just put whatever you want under the actions corrosponding to whatever dialogbutton they clicked.
02-07-2004, 06:23 AM#6
Huh
I got it working finally. What i did was made a unit variable for the unit chosen from event- player selects a unit. Then in actions of that trigger I set the variable to triggering unit.
In the trigger containing the "event-dialog button is clicked" event, I just referred back to that variable when picking which type of unit would be spawned. Not as complicated as i thought :)

Thanks for tryin to help me man.

-Huh
02-16-2004, 12:46 AM#7
SilentSpyder
I'm doing the same thing in my map, and last I tested it didn't work. I think my problem is in variable arrays. It's a 8 player map. When a player clicks on a unit, a window is suppose to come up saying "Are you sure? "Yes" or "NO. I got that to work, nothing happens when I press the button, the dialog window just goes away. So here's my question what has to be normal variables, and what arrays (because of the 8 players)? By 'what' I mean the dialog variable, and the dialog button variables? Is only one of those suppose to be arrays, or both, or none.
02-16-2004, 12:59 AM#8
Huh
Think of an array as nothing more than a bunch of the same type variable compressed into a single variable. Instead of having 8 variables for each hero, like player1hero, player2hero, player3hero, etc; you can have a variable array. For each hero just use a diff. integer attached to the variable. Like for player 1 it would be playerhero(0), playerhero(1),etc.

The trick to getting your actions to take place after a player clicks yes is to have separate triggers with event - a dialogue buttton for *** is clicked (*** is your dialog variable). Then have conditions and actions in that trigger. Just play with it, it should work. IF you absolutely cannot get it to work maybe I can take a screenshot or 2 of my setup and let you take a peek. Try to get it working on your own first tho, its alot more rewarding ^_^
02-16-2004, 01:15 AM#9
SilentSpyder
I know what a array is. And to tell you the truth I know I'll figure it out. It's just a little time consuming to go trough the whole trial and error phase. What I dont know is, do I need many(8 in array) dialog windows and many (8) buttons? Or is just one(non arrray) window and one button enough to work for 8 players?
02-16-2004, 01:40 AM#10
weaaddar
Actually the really easiest way to make a yes no dialog is this:
http://kattana.users.whitehat.dk/viewfunc.php?id=209
02-16-2004, 01:50 AM#11
Huh
if all you have is one dialog window (the yes/no window), all you should need is one non-array dialog variable, and one dialog button variable with array. You will also need one other unit variable with array to decide which hero gets selected. Here's an example of the variables you will need to create:

YesNo (dialog variable, no array)
YesNobutton (dialog button variable, with array)
SelectedHero (unit variable, with array- each corresponding number will be for the different players.. 0 for player 1, 1 for player 2, etc)


In your map init set up the dialog window like this:

Dialog - create a dialog button for YesNo labelled Yes
Set YesNobutton(0) = (Last created dialog button)
Dialog - create a dialog button for YesNo labelled No
Set YesNobutton(1) = (Last created dialog button)

in that example, YesNo is your dialog variable, and YesNobutton is the dialog button variable with array.

Once you've set that up, make 8 triggers (one for each player) to detect which player has the window shown for him/her. For each trigger its good to have an if/than/else for every possible hero that will be selected. In the event just use whatever youre using to decide how the Yes/No window is brought up (in mine i base it off of when a hero clicks on the hero). Here's an example based from my map that works good.

E: Player - Player 1 selects a unit
A: If/Than/Else
If: (Triggering Unit) Equal to HeroType1
Then: Set SelectedHero(0) = (Triggering unit)
Dialog - Change the title of YesNo to (Select + ((Name of (Triggering unit)) + ?))
Dialog - Show YesNo for (Triggering Player)

Make something similar to that for every possible hero that can be selected. If you have 10 heroes, have 10 If/than/Else statements. Then just copy/paste it 7 times, and go back through changing the event to the correct player and changing the number in the SelectedHero array to another one (0,1,2,3,4,5,6,7) for each player.

Last but not least, you will need 8 MORE triggers in order to detect which player clicks the buttons. Make the following trigger than copy/paste it 7 times and change all references to Player 1 to the corresponding player.

E: Dialog - A dialog button is clicked for YesNo
C:
A: If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Triggering player) Equal to (==) Player 1 (Red)
(Clicked dialog button) Equal to (==) YesNobutton(0)
Then - Actions
Add your actions here such as create type of hero that was chosen etc. It could be something like "Unit - create 1 HeroSelected(0) at Region01", whatever you want to do.
Else - Actions
Do Nothing

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Triggering player) Equal to (==) Player 1 (Red)
(Clicked dialog button) Equal to (==) YesNobutton(1)
Then - Actions
Dialog - Hide YesNo for Player 1 (Red)
Else - Actions
Do Nothing


OK HOPEFULLY that is what you're trying to do. There might/probably is an easier/better way to do it, but that's how I did it and it works flawlessly. Good luck :)

EDIT- Weeadars method is in JASS, which coming from him I'm sure is the best way to do it, but if you don't know hardly any JASS such as myself then my method should do the trick. THE REASON there are so many triggers is because you need one "Show dialog window" trigger for each player. Same goes for the "Clicked dialog button" trigger.
02-16-2004, 09:09 AM#12
Cubasis
Lol, darn,

Weaaddar beat me to posting that function :D

But yeah, that function is the "Easiest" method imo... if you know jass, then with that function you need ... "no triggers", "no globals", "no anything" :D

Anyhow, as you said, it's Jass...and Jass is da alien of all things hard to learn.

So i'll teach you.

First, CnP the whole function posted in that link (http://kattana.users.whitehat.dk/viewfunc.php?id=209) into the Map's header (in the trigger editor ... click the Map Name in the Trigger-List).

Then, create a Boolean Variable named whatever you want.

Then, where you want to ask the player sumtin, do this:

Custom Script; "set udg_*bool* = InputMsg(Player(*whichplayer*), "Do you really want to select this hero?", "Yes", "No")"

where:
*bool* = Your created Boolean Variable Name
*whichplayer* = What player you want to ask... This value is zero-based so Player 1 is '0', Player 2 is '1', Player 12 is '11'

Then you just use the boolean in a "if" action to do different things, f.ex.
If MyBoolVariable is Equal to True then (do actions)
---Move Unit to (center of (HeroSpawn))
Else
---Do Nothing

So, Example, i have a boolean variable named MyBool, and i want to ask Player 3.

Custom Script; "set udg_MyBool = InputMsg( Player(2), "Do you really want to select this hero?", "Yes", "No" )
If
---Condition
------MyBool equal to true
---Then Actions
------*Select Hero*
---Else Actions
------Do Nothing


Ta Daamm,

if you implement this, you're 1 step closer to becoming a Jass monkey.

Congratulations.

Cubasis