soulreaping
New Member
- Reaction score
- 17
Hey,
I'm building a nice Stratego map (if anyone knows this classic strategy game) and I'm having an issue with a dialog.
Trigger 1:
This works pretty fine. The issue is here:
All variables are global variables.
Now in-game, when I click the Marshal button, it does nothing.
The unit isn't being replaced, the unit that is suppose to be created, isn't being created.
I don't get what I miss here.
Thanks for everyone who helps!
I'm building a nice Stratego map (if anyone knows this classic strategy game) and I'm having an issue with a dialog.
Trigger 1:
JASS:
scope PlacingPhasePlayerOne
private function Conditions takes nothing returns boolean
return (IsUnitAlly(GetTriggerUnit(), Player(0)))
endfunction
private function Actions takes nothing returns nothing
set PlacingPhaseDialogP1 = DialogCreate()
if (Player1Marshal == 1) then
set Player1MarshalB = DialogAddButton(PlacingPhaseDialogP1, "Marshal (x1)", 0)
endif
if (Player1General == 1) then
set Player1GeneralB = DialogAddButton(PlacingPhaseDialogP1, "General (x1)", 0)
endif
if (Player1Colonels > 0) then
set Player1ColonelsB = DialogAddButton(PlacingPhaseDialogP1, "Colonels (x" + I2S(Player1Colonels)+")", 0)
endif
if (Player1Majors > 0) then
set Player1MajorsB = DialogAddButton(PlacingPhaseDialogP1, "Majors (x" + I2S(Player1Majors) + ")", 0)
endif
if (Player1Captains > 0) then
set Player1CaptainsB = DialogAddButton(PlacingPhaseDialogP1, "Captains (x" + I2S(Player1Captains) + ")", 0)
endif
if (Player1Lieutenants > 0) then
set Player1LieutenantsB = DialogAddButton(PlacingPhaseDialogP1, "Lieutenants (x" + I2S(Player1Lieutenants) + ")", 0)
endif
if (Player1Sergeants > 0) then
set Player1SergeantsB = DialogAddButton(PlacingPhaseDialogP1, "Sergeants (x" + I2S(Player1Sergeants) + ")", 0)
endif
if (Player1Miners > 0) then
set Player1MinersB = DialogAddButton(PlacingPhaseDialogP1, "Miners (x" + I2S(Player1Miners) + ")", 0)
endif
if (Player1Scouts > 0) then
set Player1ScoutsB = DialogAddButton(PlacingPhaseDialogP1, "Scouts (x" + I2S(Player1Scouts) + ")", 0)
endif
if (Player1Bombs > 0) then
set Player1BombsB = DialogAddButton(PlacingPhaseDialogP1, "Bombs (x" + I2S(Player1Bombs) + ")", 0)
endif
if (Player1Spy == 1) then
set Player1SpyB = DialogAddButton(PlacingPhaseDialogP1, "Spy (x1)", 0)
endif
if (Player1Flag == 1) then
set Player1FlagB = DialogAddButton(PlacingPhaseDialogP1, "Flag (x1)", 0)
endif
set TempP1Selection = GetTriggerUnit()
call DialogDisplay(Player(0), PlacingPhaseDialogP1, true)
endfunction
public function InitTrig takes nothing returns nothing
local trigger myTrig = CreateTrigger()
call TriggerRegisterPlayerSelectionEventBJ(myTrig, Player(0), true)
call TriggerAddCondition(myTrig, Condition(function Conditions))
call TriggerAddAction(myTrig, function Actions)
endfunction
endscope
This works pretty fine. The issue is here:
JASS:
scope ButtonMarshalPOne
globals
private constant integer UNIT_ID = 039;h003039;
endglobals
private function Conditions takes nothing returns boolean
return (GetClickedButton() == Player1MarshalB)
endfunction
private function Actions takes nothing returns nothing
local location loc = GetUnitLoc(TempP1Selection)
set Player1Marshal = 0
call BJDebugMsg("Hello") // <-- To check if this function is even called.
call RemoveUnit(TempP1Selection)
call CreateUnitAtLoc(Player(0), UNIT_ID, loc, bj_UNIT_FACING)
call DialogDestroy(PlacingPhaseDialogP1)
call RemoveLocation(loc)
set Player1MarshalB = null
set loc = null
set TempP1Selection = null
call DisableTrigger(GetTriggeringTrigger())
call DestroyTrigger(GetTriggeringTrigger())
endfunction
public function InitTrig takes nothing returns nothing
local trigger myTrig = CreateTrigger()
call TriggerRegisterDialogButtonEvent(myTrig, Player1MarshalB)
//call TriggerAddCondition(myTrig, Condition(function Conditions)) <-- I tried TriggerRegisterDialogEvent which then requires the condition.
call TriggerAddAction(myTrig, function Actions)
endfunction
endscope
All variables are global variables.
Now in-game, when I click the Marshal button, it does nothing.
The unit isn't being replaced, the unit that is suppose to be created, isn't being created.
I don't get what I miss here.
Thanks for everyone who helps!