Another Dialog Fail: detecting selection

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Interesting find:

Code:
TechMenu: Detect ListBox Selection
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                [COLOR="Red"][B]ListBoxSelection != 1[/B][/COLOR]
                (Selected list item of TechTypesDropdown for (Triggering player)) == 1
            Then
                [COLOR="red"][B]Variable - Set ListBoxSelection = 1[/B][/COLOR]
                TechMenu: Generate Tech List((Player group(Triggering Player)), 1)
            Else

in this you will notice that I am having to use a global variable "ListBoxSelection" of type integer in order to fix a problem that occurs when running the event type "Dialog - (Used dialog item) is Changed Selection by Player Any Player".

what happens without the global variable condition added is that the current list selection is continually counted as an event (periodically) instead of only firing after a change in selection (which is preferred). The problem I was facing without the global was that my action "generate tech list" was repeatedly being re-run for the current list selection.
 

SerraAvenger

Cuz I can
Reaction score
234
Hmm, very interesting. Thanks for pointing this out.

So you're saving the currently selected item in the variable?


May I suggest this change:
EDIT, optimized:

Code:
    Local Variables
        newSelected =  (Selected list item of TechTypesDropdown for (Triggering player)) <int>
    Conditions
        ListBoxSelection != newSelected
    Actions
        Variable - Set ListBoxSelection = newSelected
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Hmm. since last night I changed several of my "if-then" statements to "switches" because they are much more tidy and allow me to check for different used dialog items. It seems as though this problem isn't happening anymore.

actually i think the problem lies in the conditional: "(Selected list item of TechTypesDropdown for (Triggering player)) == 1"

since my new code has a new layer added that checks "used dialog"

here is how my gui looks now:

Code:
TechMenu: Detect Dialog Selections
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        Triggering Player = (Empty player group) <Player Group>
        tempInt = 0 <Integer>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        [COLOR="Red"]General - Switch (Actions) depending on (Used dialog item)[/COLOR]
            Cases
                [COLOR="Green"]General - If (TechTypesDropdown)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 5 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of TechTypesDropdown for (Triggering player)) == tempInt
                                    Then
                                        Variable - Set DropdownSelection = tempInt
                                        TechMenu: Generate Tech List(Triggering Player, tempInt)
                                        General - Break
                                    Else
                [COLOR="green"]General - If (ListBox)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default

the green parts are my dropdown and my list which are dialog items of type "used dialog" because they are the actual structure. the internal list pieces are considered "dialog items" too; however, do not respond to "used dialog" because they are not the overal structure parts. with this new layer, i no longer need to check to see if the list selected was the list previously selected.

@Serra: I'm trying to wrap my brain around your optimization. how much of a change does that make and how? what you mean is just that you don't have to look up the value of the list piece every cycle right? just once at the beginning? if so gotcha.
 

SerraAvenger

Cuz I can
Reaction score
234
Hmm. since last night I changed several of my "if-then" statements to "switches" because they are much more tidy and allow me to check for different used dialog items. It seems as though this problem isn't happening anymore.
A good change to make = )
here is how my gui looks now:

Code:
TechMenu: Detect Dialog Selections
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        Triggering Player = (Empty player group) <Player Group>
        tempInt = 0 <Integer>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        [COLOR="Red"]General - Switch (Actions) depending on (Used dialog item)[/COLOR]
            Cases
                [COLOR="Green"]General - If (TechTypesDropdown)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 5 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of TechTypesDropdown for (Triggering player)) == tempInt
                                    Then
                                        Variable - Set DropdownSelection = tempInt
                                        TechMenu: Generate Tech List(Triggering Player, tempInt)
                                        General - Break
                                    Else
                [COLOR="green"]General - If (ListBox)[/COLOR]
                    Actions
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default


@Serra: I'm trying to wrap my brain around your optimization. how much of a change does that make and how? what you mean is just that you don't have to look up the value of the list piece every cycle right? just once at the beginning? if so gotcha.

Well from your code before it was that you wouldn't need to do the "ListBoxSelection != 1" check for every single list item, but only once per dialog. (Once every cycle though)

The optimization that I wrote about was actually an optimization within my own code, where I reduced the number of function calls by one and used conditions instead of an if clause.


Anyhow, you can take out the loops completely.
Code:
                        General - For each integer tempInt from 1 to 50 with increment 1, do (Actions)
                            Actions
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Selected list item of ListBox for (Triggering player)) == tempInt
                                    Then
                                        Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][tempInt].info)) for Triggering Player
                                        General - Break
                                    Else
                                        Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
->
Code:
If
    [An item is selected] // I don't know the correct GUI script and I don't have SC2 on this system
Then
    Dialog - Set InfoBox text to (Text(Tech Item[DropdownSelection][newSelected].info)) for Triggering Player
Else
    Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player


actually i think the problem lies in the conditional: "(Selected list item of TechTypesDropdown for (Triggering player)) == 1"

since my new code has a new layer added that checks "used dialog"
Btw, are you sure your function still fires at all? And if it does, did you check if it really runs only once with the help of some debug messages?
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Mmmhmm it works perfectly as is. once per selection and all. error messages confirmed that before I posted last.

[EDIT] i'll remove the loops. ^^ Guess I started getting a bit off track at some point.
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
works without the loops wonderfully as well.


Dialog - (Used dialog item) is Changed Selection by Player Any Player

reconfirmed not to fire unless a change in selection is made with error text... so i'm going to plug my old code in once more with error text this time to see if it fires more than once... what was happening before is that my list just kept being regenerated which was evident by trying to click any list item (and then it being deselected). There was no tricky parts, my code was exactly as stated in the first post so very interesting... it really seems as though the switch instead of the if-then made a huge enough difference because of the "used dialog" layer added.

Let me reconfirm what i'm thinking and we will talk again... I'm telling you, dialogs have ridiculous GUI in this editor. I feel like dialoging could use some lovin' from what we have now...
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Ok I'm putting this to rest because I kind of figured it out but am pretty tired of this.

Code:
TechMenu: Detect Dialog Selections 3
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                (Selected list item of TechTypesDropdown for (Triggering player)) == 1
            Then
                UI - Display "WTF!?!?" for (All players) to Subtitle area
                TechMenu: Generate Tech List((Player group((Triggering player))), 1)
            Else

"WTF!?!?" fires twice at a time when hitting a list (sometimes... at least) just some kind of confusion over what a "used item" and "selected item" is i suppose. interestingly enough a list item is a dialog item and the list itself is a dialog item as well... so i think that's the problem. redundancy.

final code:

Code:
TechMenu: Detect Dialog Selections 2
    Events
        Dialog - (Used dialog item) is Changed Selection by Player Any Player
    Local Variables
        TTD_Selection = (Selected list item of TechTypesDropdown for (Triggering player)) <Integer>
        LB_Selection = (Selected list item of ListBox for (Triggering player)) <Integer>
        Triggering Player = (Empty player group) <Player Group>
    Conditions
    Actions
        Variable - Set Triggering Player = (Player group((Triggering player)))
        General - Switch (Actions) depending on (Used dialog item)
            Cases
                General - If (TechTypesDropdown)
                    Actions
                        TechMenu: Generate Tech List(Triggering Player, TTD_Selection)
                General - If (ListBox)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Selected list item of ListBox for (Triggering player)) != 0
                            Then
                                Dialog - Set InfoBox text to "" for Triggering Player
                                Dialog - Set InfoBox text to (Text(Tech Item[TTD_Selection][LB_Selection].info)) for Triggering Player
                            Else
                                Dialog - Set InfoBox text to "" for Triggering Player
                                Dialog - Set InfoBox text to "Choose a technology piece in the li..." for Triggering Player
            Default

seems to be working fine. I'm going to go pray to Blizzard to fix their dialog issues and then go to bed. may this thread help someone...
 

SerraAvenger

Cuz I can
Reaction score
234
interestingly enough a list item is a dialog item and the list itself is a dialog item as well... so i think that's the problem. redundancy.

That's exactly why I wondered if your code actually works. I thought they were distinct.

Meh, Blizzard is doing weird stuff again.

If I'm back on Windows, I'll think about a new GUI dialogs library...
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top