• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Dialogs

Status
Not open for further replies.
Level 4
Joined
Aug 8, 2011
Messages
84
So I've been using global variables for Dialogs / Dialog buttons for a long time, but I wanted to move away from this and simply use a struct housing the needed elements for simplicity.

My struct:

JASS:
struct dialogdat
    dialog Diag = DialogCreate()
    button array Buttons[12]
endstruct

I have the struct saved to a player ID in a hashtable, shortly after game initialization, and am trying to recall the struct from the ID of the player after they click a button on the dialog. This way I can do:

JASS:
    loop
        exitwhen(clicked == D.Buttons[i])
        set i = i + 1
    endloop

To easily figure out what was pressed. The problem, however, is that the function attached to the dialog isn't running, regardless of which button is pressed.

JASS:
function blah takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local integer pID = GetConvertedPlayerId(p)
    local button clicked = GetClickedButton()
    local integer i = 0
    local trigger allocate = CreateTrigger()
    local dialogdat D = LoadInteger(udg_Hash, StringHashBJ("diag"), GetHandleId(p))
    local playerdat S = LoadInteger(udg_Hash, StringHashBJ("heroinfo"), GetHandleId(p))
        
        call DialogClear(D.Diag)
        call DialogSetMessage(D.Diag, "yo:")
        
        loop
            exitwhen(i > S.NumMemSkills - 1) 
            set D.Buttons[i] = DialogAddButton(D.Diag, GetObjectName(S.MemSkillID[i]), i)
            set i = i + 1
        endloop
        
        call DialogDisplay(p, D.Diag, true)
        
        call TriggerAddAction(allocate, function blah2)
        call TriggerRegisterDialogEvent(allocate, D.Diag)
endfunction

S is a different struct type, whose data members function just fine, and yet is loaded in the same manner, so I am confused as to why just the dialog doesn't work.

EDIT: I have solved my problem, thank you.
 
Last edited:
Status
Not open for further replies.
Top