- Joined
- Feb 11, 2011
- Messages
- 1,860
I am trying the create a dialog system for choosing the difficulty and game mode. However, it doesn't work! Here are the scripts:
What happens: The first dialog creates successfully. However, when I click Button[2], it should display the text "Normal selected" and create a new dialog for game mode selection, but it doesn't.
Any ideas?
JASS:
globals
dialog Dialog
button array Button
endglobals
JASS:
function DifficultyDialog takes nothing returns nothing
set Dialog = DialogCreate()
call DialogClear(Dialog)
call DialogSetMessage(Dialog, "Select Difficulty")
set Button[1] = DialogAddButton(Dialog, "Easy", 0)
set Button[2] = DialogAddButton(Dialog, "Normal", 0)
set Button[3] = DialogAddButton(Dialog, "Hard", 0)
call DialogDisplay(Player(0), Dialog, true)
endfunction
JASS:
library Dialog initializer InitTrigger
private function Actions takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
if GetClickedButton() == Button[1] then
set Game_Difficulty = "Easy"
elseif GetClickedButton() == Button[2] then
set Game_Difficulty = "Normal"
call BJDebugMsg("Normal selected.")
elseif GetClickedButton() == Button[3] then
set Game_Difficulty = "Hard"
endif
call DialogClear(Dialog)
call DialogSetMessage(Dialog, "Choose Game Mode")
set Button[4] = DialogAddButton(Dialog, "Normal", 0)
set Button[5] = DialogAddButton(Dialog, "No Special Creeps", 0)
set Button[6] = DialogAddButton(Dialog, "No Bosses", 0)
call DialogDisplay(Player(0), Dialog, true)
endfunction
private function InitTrigger takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterDialogButtonEvent(t, Button[1])
call TriggerRegisterDialogButtonEvent(t, Button[2])
call TriggerRegisterDialogButtonEvent(t, Button[3])
call TriggerAddAction(t, function Actions)
set t = null
endfunction
endlibrary
What happens: The first dialog creates successfully. However, when I click Button[2], it should display the text "Normal selected" and create a new dialog for game mode selection, but it doesn't.
Any ideas?