Dialog Problem

Tinki3

Special Member
Reaction score
418
I've created a small dialog trigger so that player red can choose the game difficulty.

However, I seem to be having a strange problem that seemingly relates to the dialog's buttons.
JASS:
scope ChooseDifficulty

globals
    private constant real Initial_Delay = 3
    private constant integer Text_Dur = 15
    private constant string Dialog_Title = "Choose the game difficulty"
    private constant string Easy_String = "Game difficulty set to: Easy"
    private constant string Normal_String = "Game difficulty set to: Normal"
    private constant string Hard_String = "Game difficulty set to: Hard"
    dialog d = DialogCreate()
    button array buttons
    triggeraction ta
endglobals

private function Dialog_Actions takes nothing returns nothing
    if GetClickedButton() == buttons[1] then
        call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, Text_Dur, Easy_String)
    elseif GetClickedButton() == buttons[2] then
        call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, Text_Dur, Normal_String)
    elseif GetClickedButton() == buttons[3] then
        call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, Text_Dur, Hard_String)
    endif
    
    call DialogDestroy(d)
    call TriggerRemoveAction(GetTriggeringTrigger(), ta)
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

private function Create_Dialog takes nothing returns nothing
    local trigger t = CreateTrigger()
       
    call DialogClear(d)
    call DialogSetMessage(d, Dialog_Title)
    call DialogAddButton( d, "Easy", 0)
    set buttons[1] = bj_lastCreatedButton
    call DialogAddButton( d, "Normal", 0)
    set buttons[2] = bj_lastCreatedButton
    call DialogAddButton( d, "Hard", 0)
    set buttons[3] = bj_lastCreatedButton
    call DialogDisplay(Player(0), d, true)
    
    call TriggerRegisterDialogEvent(t, d)
    set ta = TriggerAddAction(t, function Dialog_Actions)
    
    set t = null
endfunction

function InitTrig_Difficulty takes nothing returns nothing
    local trigger t = CreateTrigger ()
    call TriggerRegisterTimerEvent(t, Initial_Delay, false)
    call TriggerAddAction( t, function Create_Dialog )
    set t = null
endfunction

endscope

The text-displaying actions don't work at all in the Dialog_Actions function.
But, if I place one outside the If-Then-Else statement, the text shows just fine.

Have I missed something here?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
DialogAddButton does not set the bj_lastCreatedButton. That's done with DialogAddButtonBJ.

So, do this:

set buttons[1] = DialogAddButton...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top