vJass Triggers
I thought I knew what I was doing when writing this, but obviously I didn't.
I chose to do like this because I wanted more structure in my game mechanics.
1. The first trigger is a library containing globals and functions.
2. The second trigger is in which the "triggers" are created, adding events and actions.
The actions that are called is functions from the first trigger's library.
Do not analyze the content of the functions.
My question is why only the first trigger (startOfGame) is working.
Nothing happens when I press the Buttons of the Dialog.
1.
2.
Can anyone explain this to me? Any info on how triggers are created and works is much appreciated.
If there are any good tutorials dealing with vJass triggers please link.
I thought I knew what I was doing when writing this, but obviously I didn't.
I chose to do like this because I wanted more structure in my game mechanics.
1. The first trigger is a library containing globals and functions.
2. The second trigger is in which the "triggers" are created, adding events and actions.
The actions that are called is functions from the first trigger's library.
Do not analyze the content of the functions.
My question is why only the first trigger (startOfGame) is working.
Nothing happens when I press the Buttons of the Dialog.
1.
JASS:
//-----------------------
// Game Globals
//-----------------------
globals
dialog Dialog = DialogCreate()
timer Tim = CreateTimer()
timerdialog TimDialog = CreateTimerDialog(Tim)
constant integer NrOfModes = 3
boolean array Mode [NrOfModes]
constant integer MODE_RANDOM = 0
constant integer MODE_SIDES = 1
constant integer MODE_FORTRESS = 2
constant integer MODE_GUERILLA = 3
boolean MatchOn = false
boolean SandboxOn = false
boolean Pause = false
button Btn_Random
button Btn_Sides
button Btn_Fortress
button Btn_Guerilla
endglobals
//-----------------------
// Game Structure
//-----------------------
library dialogs
public function Mode takes nothing returns nothing
call DialogSetMessage(Dialog, "Choose Mode!")
set Btn_Random = DialogAddButton(Dialog, "Random", 0)
set Btn_Sides = DialogAddButton(Dialog, "Sides", 1)
set Btn_Fortress = DialogAddButton(Dialog, "Fortress", 2)
set Btn_Guerilla = DialogAddButton(Dialog, "Guerilla", 3)
call DialogDisplay(Player(0), Dialog, true)
call TimerStart(Tim, 10.0, false, null)
call TimerDialogSetTitle(TimDialog, "Round Starts In")
call TimerDialogDisplay(TimDialog, true)
endfunction
endlibrary
library terrain
public function PrepareTerrain takes nothing returns nothing
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Preparing terrain")
endfunction
endlibrary
library mode requires phase
public function Sides takes nothing returns nothing
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Mode: Sides")
call PauseTimer(Tim)
call TimerDialogDisplay(TimDialog, false)
set Mode[MODE_SIDES] = true
call phase_sandbox_Start()
endfunction
public function Fortress takes nothing returns nothing
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Mode: Fortress")
set Mode[MODE_FORTRESS] = true
call phase_sandbox_Start()
endfunction
public function Guerilla takes nothing returns nothing
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Mode: Guerilla")
set Mode[MODE_GUERILLA] = true
call phase_sandbox_Start()
endfunction
public function Random takes nothing returns nothing
local integer i = GetRandomInt(1, NrOfModes)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Setting random Mode")
if i == MODE_SIDES then
call Sides()
elseif i == MODE_FORTRESS then
call Fortress()
elseif i == MODE_GUERILLA then
call Guerilla()
endif
endfunction
endlibrary
library phase
scope match
private function End takes nothing returns nothing
set MatchOn = false
endfunction
public function Start takes nothing returns nothing
set MatchOn = true
endfunction
endscope
scope sandbox
private function End takes nothing returns nothing
set SandboxOn = false
endfunction
public function Start takes nothing returns nothing
set SandboxOn = true
endfunction
endscope
scope init
public function Preparations takes nothing returns nothing
call dialogs_Mode()
endfunction
endscope
endlibrary
2.
JASS:
scope startOfGame initializer Init
public function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterTimerEvent(Trig, 0.01, false)
call TriggerAddAction(Trig, function phase_init_Preparations)
endfunction
endscope
scope modeSidesClicked initializer Init
public function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterDialogButtonEvent(Trig, Btn_Sides)
call TriggerAddAction(Trig, function mode_Sides)
endfunction
endscope
scope modeFortressClicked initializer Init
public function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterDialogButtonEvent(Trig, Btn_Fortress)
call TriggerAddAction(Trig, function mode_Fortress)
endfunction
endscope
scope modeGuerillaClicked initializer Init
public function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterDialogButtonEvent(Trig, Btn_Guerilla)
call TriggerAddAction(Trig, function mode_Guerilla)
endfunction
endscope
scope modeRandomClicked initializer Init
public function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterDialogButtonEvent(Trig, Btn_Random)
call TriggerAddAction(Trig, function mode_Random)
endfunction
endscope
Can anyone explain this to me? Any info on how triggers are created and works is much appreciated.
If there are any good tutorials dealing with vJass triggers please link.