Dialog buttons "need help!"

Muddis

New Member
Reaction score
0
I been trying to create a trigger that when i press a dialog button it will add a new button but for every time i press the button it will create a new button at another spot up to like 4 buttons.

Ok so far i got this going:

Code:
   Test 1
    Events
        Dialog - Any Dialog Item is Clicked by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Dialog Button[Test] == Dialog Button[0]
            Then
                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Top Left with an offset of (50, 50) setting the tooltip to "" with button text "Test 1" and the hover image set to ""
                Variable - Modify Test: + 1
                Variable - Set Dialog Button[Test] = (Last created dialog item)
            Else
                General - If (Conditions) then do (Actions) else do (Actions)
                    If
                        Dialog Button[Test] == Dialog Button[1]
                    Then
                        Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Bottom Right with an offset of (50, 50) setting the tooltip to "" with button text "Test 2" and the hover image set to ""
                        Variable - Modify Test: + 1
                        Variable - Set Dialog Button[Test] = (Last created dialog item)
                    Else
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                Dialog Button[Test] == Dialog Button[2]
                            Then
                                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Top Right with an offset of (50, 50) setting the tooltip to "" with button text "Test 3" and the hover image set to ""
                                Variable - Modify Test: + 1
                                Variable - Set Dialog Button[Test] = (Last created dialog item)
                            Else
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        Dialog Button[Test] == Dialog Button[3]
                                    Then
                                        Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Right with an offset of (50, 50) setting the tooltip to "" with button text "Test 4" and the hover image set to ""
                                        Variable - Modify Test: + 1
                                        Variable - Set Dialog Button[Test] = (Last created dialog item)
                                    Else

Test 2
    Events
        Dialog - Any Dialog Item is Clicked by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[1]
            Then
                Dialog - Destroy Dialog Button[1]
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[2]
            Then
                Dialog - Destroy Dialog Button[2]
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[3]
            Then
                Dialog - Destroy Dialog Button[3]
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[4]
            Then
                Dialog - Destroy Dialog Button[4]
            Else

so i got the press more then one time to create a button at another place going, but i dont know how to set it so when i destroy a button it will place the new button at that spot.
 

bobby5589

Member
Reaction score
15
How about you post the triggers you have so we can say what your doing wrong? It'll be better then someone writting up something new for ya.
 

SerraAvenger

Cuz I can
Reaction score
234
Here's a code example from my TeamLib library:
JASS:
int[31] libsatm_gv_FreeTeamIds;
bool[31] libsatm_gv_TeamActive;
int libsatm_gv_TeamsTotal;
int libsatm_gv_NextFreeTeam;

int libsatm_gf_TeamCreate () {
    // Variable Declarations
    int lv_team;

    // Variable Initialization
    lv_team = 0;

    // Implementation
    if (libsatm_gv_NextFreeTeam==-1) {
        libsatm_gv_TeamsTotal += 1;
        lv_team = libsatm_gv_TeamsTotal;
    }
    else{
        lv_team = libsatm_gv_FreeTeamIds[libsatm_gv_NextFreeTeam];
        libsatm_gv_NextFreeTeam -= 1;
    }
    libsatm_gv_TeamActive[lv_team]=true;
    return lv_team;
}


void libsatm_gf_DestroyTeam (int lp_team) {
    // Variable Declarations
    playergroup lv_group;

    // Variable Initialization
    lv_group = libsatm_gv_TeamPlayers[lp_team];

    // Implementation
    if (libsatm_gv_TeamActive[lp_team]) {
        libsatm_gv_TeamActive[lp_team] = false;
        libsatm_gv_NextFreeTeam += 1;
        libsatm_gv_FreeTeamIds[libsatm_gv_NextFreeTeam] = lp_team;
    }
}


Yeah, this doesn't create any dialogs, but it shows how to recycle array positions.
 

Muddis

New Member
Reaction score
0
i understand like 0% of that xD

I only got understanding of Triggering with Arry and no custom or prefix or what it's called
 

bobby5589

Member
Reaction score
15
Well, your issue is that once you creat the 4th button "test" = 4. So, when you go and create another button it won't create one because it's running through your first trigger looking for {Dialog Button[Test]} or {Dialog Button[4]} which you don't handle.

So, basicly, the button you deleted won't be replaced becuase you've already set "test" for the next button and after the fourth no more can be created becuase "test" is higher then the first trigger is looking for (ie it goes through all the if statements and nothing happens).
 

bobby5589

Member
Reaction score
15
I assume you want it to fill in, but not replace so a quick fix would be..

1. to set "test" to the lowest missing button when deleting. (ex. set test to 3 if test is > 3 )
2. when creating a button, first check if the button exists and if so increment test (a loop would clean up those ifs some)

If you have trouble doing that, I'll write it out for ya.
 

Muddis

New Member
Reaction score
0
This is what i got.

Code:
   Test 1
    Events
        Dialog - Any Dialog Item is Clicked by Player Any Player
    Local Variables
    Conditions
        (Used dialog item) == Dialog Button[0]
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Dialog Button[Test] == Dialog Button[3]
            Then
                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Left with an offset of (0, 50) setting the tooltip to "" with button text "Test 4" and the hover image set to ""
                Variable - Modify Test: + 1
                Variable - Set Dialog Button[Test] = (Last created dialog item)
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Dialog Button[Test] == Dialog Button[2]
            Then
                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Top Right with an offset of (50, 50) setting the tooltip to "" with button text "Test 3" and the hover image set to ""
                Variable - Modify Test: + 1
                Variable - Set Dialog Button[Test] = (Last created dialog item)
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Dialog Button[Test] == Dialog Button[1]
            Then
                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Bottom Right with an offset of (50, 50) setting the tooltip to "" with button text "Test 2" and the hover image set to ""
                Variable - Modify Test: + 1
                Variable - Set Dialog Button[Test] = (Last created dialog item)
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Dialog Button[Test] == Dialog Button[0]
            Then
                Dialog - Create a Button for Dialog Main Dialog with the dimensions (200, 50) anchored to Top Left with an offset of (50, 50) setting the tooltip to "" with button text "Test 1" and the hover image set to ""
                Variable - Modify Test: + 1
                Variable - Set Dialog Button[Test] = (Last created dialog item)
            Else

   Test 2
       Events
        Dialog - Any Dialog Item is Clicked by Player Any Player
    Local Variables
    Conditions
        (Used dialog item) != Dialog Button[0]
        (Used dialog item) != Show/hide UI
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[1]
            Then
                Variable - Set Test = 0
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[2]
            Then
                Variable - Set Test = 1
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[3]
            Then
                Variable - Set Test = 2
            Else
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Used dialog item) == Dialog Button[4]
            Then
                Variable - Set Test = 3
            Else
        Dialog - Destroy (Used dialog item)

The new problem is if i click Test 1 and 4 it will only redo the last button :S any way around that? and if you would like, i would love a example of Loops and if you do it with my trigger i would be endlessly grateful :D
 

bobby5589

Member
Reaction score
15
I'll go ahead and write it up for ya to see 'cause that's starting to look a bit messy. Give me a few mins to type and I'll edit this post. :D

[edit] I take back what I said 'bout the loop. Try this, it should do what you want and it's more like what you were trying to do first.

Create Dialog Button creates a button at the first DialogButton[#] that isn't assigned a button.

Delete Dialog Button deletes the button you press and sets DialogButton[#] equal to no button so if Create Dialog Button is run, that button will get created in the correct order if its empty.


Trigger:
  • DialogButton = No Dialog Item <Dialog Item[4]>



Trigger:
  • Create Dialog Button
    • Events
      • Dialog - Any Dialog Item is Clicked by Player Any Player
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • DialogButton[0] == No Dialog Item
        • Then
          • Dialog - Create a Button for Dialog ....
          • Variable - Set Dialog Button[0] = (Last created dialog item)
        • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • DialogButton[1] == No Dialog Item
            • Then
              • Dialog - Create a Button for Dialog ....
              • Variable - Set Dialog Button[1] = (Last created dialog item)
            • Else
              • General - If (Conditions) then do (Actions) else do (Actions)
                • If
                  • DialogButton[2] == No Dialog Item
                • Then
                  • Dialog - Create a Button for Dialog ....
                  • Variable - Set Dialog Button[2] = (Last created dialog item)
                • Else
                  • General - If (Conditions) then do (Actions) else do (Actions)
                    • If
                      • DialogButton[3] == No Dialog Item
                    • Then
                      • Dialog - Create a Button for Dialog ....
                      • Variable - Set Dialog Button[3] = (Last created dialog item)
                      • Else




Trigger:
  • Delete Dialog Button
    • Events
      • Dialog - Any Dialog Item is Clicked by Player Any Player
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Used dialog item) == DialogButton[0]
        • Then
          • Dialog - Destroy (Used dialog item)
          • Variable - Set Dialog Button[0] = No Dialog Item
        • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Used dialog item) == DialogButton[1]
            • Then
              • Dialog - Destroy (Used dialog item)
              • Variable - Set Dialog Button[1] = No Dialog Item
            • Else
              • General - If (Conditions) then do (Actions) else do (Actions)
                • If
                  • (Used dialog item) == DialogButton[2]
                • Then
                  • Dialog - Destroy (Used dialog item)
                  • Variable - Set Dialog Button[2] = No Dialog Item
                • Else
                  • General - If (Conditions) then do (Actions) else do (Actions)
                    • If
                      • (Used dialog item) == DialogButton[3]
                    • Then
                      • Dialog - Destroy (Used dialog item)
                      • Variable - Set Dialog Button[3] = No Dialog Item
                      • Else
 

Muddis

New Member
Reaction score
0
oh yeah. will this work with 2 players?

or do i need to do two dialogs? and only show them for player 1 - 2

Is there a way to make the button created to be random between like 10 diffrent buttons?
 

bobby5589

Member
Reaction score
15
You'll need the 2 dialogs and 2 "DialogButton = No Dialog Item <Dialog Item[4]>" or you can make it a 2D array (the next box under where you set it to 4), "DialogButton = No Dialog Item <Dialog Item[4][2]>

You should be able to it with just these 2 triggers, just check the player first if you do 2 DialogButtons or if you do the 2D array modify to the code to be something like " (Used dialog item) == DialogButton[0][((Triggering player) - 1]" and do that the whole way through. {I think Neutral is 0 and Player 1 is actually 1, not sure so you'll have to test it.}

[edit] If you wanted that their actions affect each other you only need one dialog. I assumed you wanted separate for each.
 

Muddis

New Member
Reaction score
0
yeah i was almost sure i neede two dialogs buy anyway. any way to make the button random? say i have Spawn Zealot and a Spawn Stalker. i dont want you to get the Spawn Zealot button all the time.

I'm making a map where you "draw" a Unit that you can play out on the battle field so i might have 30+ units and i want it to random between them.
 

bobby5589

Member
Reaction score
15
That would be so easy if you could convert Text to String, but you can't. :(

I can think of two ways to do it, 1. by getting the unit type from the dialog button image path and 2. by making a 2D/3D integer variable storing the dialogbutton/player and the unit type as an integer. As you can see, both are a bit complicated.

Which would you prefer? 1. Is more messy, but 2. (I'm pretty sure) takes up more file space allocated to code.

Either way, for the random button change "Dialog - Create a Button for Dialog ...." to create a different button based on a random integer. Something like "RandomInt = Math - Random int 0 to 30" followed up with yet more if statements. XP {It's messy in GUI, there's no IfElse in GUI that I know of}
 

Muddis

New Member
Reaction score
0
hmm... would it be much more easy if i would use a unit and add Abilitys to him and just forget the dialog idea? i just wanted the dialog to make it look nice :p
 

bobby5589

Member
Reaction score
15
I can't say, haven't done much with the data editor.

I can continue to help with the UI if you want. Hopefully Blizz. will add more supported things later, eh?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top