- Joined
- Sep 8, 2004
- Messages
- 633
Howdy! I'm using the key press event for a camera system in my map. Now it has to do this for each player, using a global boolean.
Naturally, I can start copying and pasting the trigger over and over and over. However, I would prefer to do it a more efficient way. Is there any? If so, please tell me!
EDIT:
Okay, after some tinkering, I've made this; opinions?
JASS:
//TESH.scrollpos=1
//TESH.alwaysfold=0
function Trig_RotateLeft_Actions takes nothing returns nothing
set udg_Boo_Camsys_LeftPressed[1] = true
endfunction
//===========================================================================
function InitTrig_RotateLeft takes nothing returns nothing
set gg_trg_RotateLeft = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeft, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_RotateLeft, function Trig_RotateLeft_Actions)
endfunction
Naturally, I can start copying and pasting the trigger over and over and over. However, I would prefer to do it a more efficient way. Is there any? If so, please tell me!
EDIT:
Okay, after some tinkering, I've made this; opinions?
JASS:
function Trig_RotateLeftAll_Actions takes nothing returns nothing
local integer Index
set Index = 1
loop
exitwhen Index > 5
if ( GetTriggerPlayer() == udg_Player[Index] ) then
set udg_Boo_Camsys_LeftPressed[Index] = true
endif
set Index = Index + 1
endloop
endfunction
//===========================================================================
function InitTrig_RotateLeftAll takes nothing returns nothing
set gg_trg_RotateLeftAll = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeftAll, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeftAll, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeftAll, Player(2), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeftAll, Player(3), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_RotateLeftAll, Player(4), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_RotateLeftAll, function Trig_RotateLeftAll_Actions )
endfunction
Last edited: