Working with key events

Arkan

Nobody rides for free
Reaction score
92
First time I'm working with key events, I'd like to know these questions...

1. Is there a function like GetPressedKey()? I couldn't find any...

2. Assuming 1. doesn't exist, would this be a good work-around (it would be MPI right?)?
JASS:
function Scroll_in_inventory_con takes nothing returns boolean
    return true
endfunction

function Scroll_Actions takes integer key returns nothing
    //actions
endfunction

function Scroll_Left takes nothing returns nothing
    call Scroll_Actions(0)
endfunction
function Scroll_Right takes nothing returns nothing
    call Scroll_Actions(1)
endfunction
function Scroll_Down takes nothing returns nothing
    call Scroll_Actions(2)
endfunction
function Scroll_Up takes nothing returns nothing
    call Scroll_Actions(3)
endfunction

//===========================================================================
function InitTrig_ItemScroll takes nothing returns nothing
    local integer i = 0
    local trigger t1 = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local trigger t3 = CreateTrigger()
    local trigger t4 = CreateTrigger()
    loop
        exitwhen i>LastPlayerIndex
        call TriggerRegisterPlayerEvent(t1,Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN)
        call TriggerRegisterPlayerEvent(t2,Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN)
        call TriggerRegisterPlayerEvent(t3,Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
        call TriggerRegisterPlayerEvent(t4,Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
        set i=i+1
    endloop
    call TriggerAddCondition(t1,Condition(function Scroll_in_inventory_con))
    call TriggerAddCondition(t2,Condition(function Scroll_in_inventory_con))
    call TriggerAddCondition(t3,Condition(function Scroll_in_inventory_con))
    call TriggerAddCondition(t4,Condition(function Scroll_in_inventory_con))
    call TriggerAddAction(t1, function Scroll_Left )
    call TriggerAddAction(t2, function Scroll_Right )
    call TriggerAddAction(t3, function Scroll_Down )
    call TriggerAddAction(t4, function Scroll_Up )
endfunction

Forgot I need to pass player index aswell.
 

SFilip

Gone but not forgotten
Reaction score
634
1. Not quite, but see below.
2. Sort of, yeah, but you can also use GetTriggerEventId() which should return EVENT_PLAYER_ARROW_LEFT_DOWN, EVENT_PLAYER_ARROW_RIGHT_DOWN, EVENT_PLAYER_ARROW_DOWN_DOWN or EVENT_PLAYER_ARROW_UP_DOWN depending on the event which triggered, assuming you have all four registered for the same trigger.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top