• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Removing Dialog Buttons from dialog after button is pressed

Status
Not open for further replies.
Level 3
Joined
Jul 21, 2010
Messages
31
Hi,

Is there anyway to create a dialogue that once a button within it is pressed, that button is removed and does not appear in the dialogue when it is shown again?
 
Level 3
Joined
Jul 21, 2010
Messages
31
Thanks, so there isnt a way of doing it more accurately?

For example if I am building a dialogue box with 4 buttons. 3 for which trigger short dialogue and a 4th button which allows the user to leave.

If I do it in the way of re-adding buttons I can go into a loop where I would be re-adding the button over and over again.

Say I press button 1 - and remove it by adding back 2,3,4.
But if I were to press 2, how could I make the editor know that 1 has already been pressed and only 3,4 need to be added?

Because there could be a scenario where 2 is pressed first and so I would re-add 1,3,4 but then if I press 1 again, I would be re-adding 2,3,4
 
Level 9
Joined
Jul 30, 2018
Messages
445
You just have to make for example a boolean variable: Button1Pressed, Button2Pressed.. etc. Then when you click a button, turn that boolean true. Then when you create the dialog, check for each button IF (Button1Pressed == false) THEN (Create button).
 
Level 2
Joined
May 28, 2019
Messages
13
I have gotten this working although my solution might not be as pretty / fluent as it should be.

Variables (I didn't spend a lot of time thinking of a good name for them lol)
ButtonsInteger - This is an integer variable with array size 4 (or however many buttons you will have)
Buttons - This is a dialog button variable with array size 4 (or however many buttons you will have)
Dialog - This is a dialog variable, no array

  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Dialog - Create a dialog button for Dialog labelled 1
      • Set Buttons[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 2
      • Set Buttons[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 3
      • Set Buttons[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 4
      • Set Buttons[4] = (Last created dialog Button)
      • Dialog - Show Dialog for Player 1 (Red)
  • Untitled Trigger 002
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
    • Actions
      • If ((Clicked dialog button) Equal to Buttons[1]) then do (Set ButtonsInteger[1] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[2]) then do (Set ButtonsInteger[2] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[3]) then do (Set ButtonsInteger[3] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[4]) then do (Set ButtonsInteger[4] = 1) else do (Do nothing)
      • Dialog - Clear Dialog
      • If (ButtonsInteger[1] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 1) else do (Do nothing)
      • Set Buttons[1] = (Last created dialog Button)
      • If (ButtonsInteger[2] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 2) else do (Do nothing)
      • Set Buttons[2] = (Last created dialog Button)
      • If (ButtonsInteger[3] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 3) else do (Do nothing)
      • Set Buttons[3] = (Last created dialog Button)
      • If (ButtonsInteger[4] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 4) else do (Do nothing)
      • Set Buttons[4] = (Last created dialog Button)
      • If ((ButtonsInteger[1] Equal to 0) or ((ButtonsInteger[2] Equal to 0) or ((ButtonsInteger[3] Equal to 0) or (ButtonsInteger[4] Equal to 0)))) then do (Dialog - Show Dialog for Player 1 (Red)) else do (Do nothing)
EDIT: Cleaned up some unneeded code in there
 
Last edited:
Level 3
Joined
Jul 21, 2010
Messages
31
Great, Thanks guys! Not sure why my brain hasnt thought of booleans to determine buttons, but hey thats why im here xD
 
Level 9
Joined
Jul 30, 2018
Messages
445
I have gotten this working although my solution might not be as pretty / fluent as it should be.

Variables (I didn't spend a lot of time thinking of a good name for them lol)
ButtonsInteger - This is an integer variable with array size 4 (or however many buttons you will have)
Buttons - This is a dialog button variable with array size 4 (or however many buttons you will have)
Dialog - This is a dialog variable, no array

  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Dialog - Create a dialog button for Dialog labelled 1
      • Set Buttons[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 2
      • Set Buttons[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 3
      • Set Buttons[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog labelled 4
      • Set Buttons[4] = (Last created dialog Button)
      • Dialog - Show Dialog for Player 1 (Red)
  • Untitled Trigger 002
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
    • Actions
      • If ((Clicked dialog button) Equal to Buttons[1]) then do (Set ButtonsInteger[1] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[2]) then do (Set ButtonsInteger[2] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[3]) then do (Set ButtonsInteger[3] = 1) else do (Do nothing)
      • If ((Clicked dialog button) Equal to Buttons[4]) then do (Set ButtonsInteger[4] = 1) else do (Do nothing)
      • Dialog - Clear Dialog
      • If (ButtonsInteger[1] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 1) else do (Do nothing)
      • Set Buttons[1] = (Last created dialog Button)
      • If (ButtonsInteger[2] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 2) else do (Do nothing)
      • Set Buttons[2] = (Last created dialog Button)
      • If (ButtonsInteger[3] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 3) else do (Do nothing)
      • Set Buttons[3] = (Last created dialog Button)
      • If (ButtonsInteger[4] Equal to 0) then do (Dialog - Create a dialog button for Dialog labelled 4) else do (Do nothing)
      • Set Buttons[4] = (Last created dialog Button)
      • If ((ButtonsInteger[1] Equal to 0) or ((ButtonsInteger[2] Equal to 0) or ((ButtonsInteger[3] Equal to 0) or (ButtonsInteger[4] Equal to 0)))) then do (Dialog - Show Dialog for Player 1 (Red)) else do (Do nothing)
EDIT: Cleaned up some unneeded code in there

Actually, you have to use If - Then - Else - multiple actions and then move the Set Buttons[X] = (Last created dialog button) inside the if-statement, because now it may assign the variable to wrong button.

For example, if button 2 is already pressed, so it won't create button 2 again, it will then assign Buttons[2] to button 1, because that's the last created dialog button.

Also, the single line if-statements are just bad, in my opinion. They don't bring anything good to the table, and yet they are harder to read and complicated to modify if you decide to change the code at some point.
 
Last edited:
Status
Not open for further replies.
Top