Thread: KeyAction
View Single Post
Old 10-15-2014, 11:20 AM   #12
Yrth
User
 
Yrth's Avatar
 
Join Date: Jul 2010
Posts: 76

Yrth has little to show at this moment (4)

Default

this bug doesnt break anything but definitely a bad bug for how easy the fix is...
Collapse JASS:
private function OnInit takes nothing returns nothing
    local integer i
    
    //! textmacro KeyAction_RegisterEvents takes KEY, DIR
        set i = 0
        loop
            exitwhen i > 11
            
            // The actual event
            call TriggerRegisterPlayerEvent(key_$KEY$_$DIR$, Player(i), EVENT_PLAYER_ARROW_$KEY$_$DIR$)
            
            // For the functions
            call TriggerAddCondition(key_$KEY$_$DIR$, Condition(function HandleKeyEventFunc_$KEY$_$DIR$))
            
            set i = i + 1
        endloop
    //! endtextmacro
    
    //! runtextmacro KeyAction_RegisterEvents("UP",    "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("UP",    "UP")
    //! runtextmacro KeyAction_RegisterEvents("DOWN",  "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("DOWN",  "UP")
    //! runtextmacro KeyAction_RegisterEvents("LEFT",  "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("LEFT",  "UP")
    //! runtextmacro KeyAction_RegisterEvents("RIGHT", "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("RIGHT", "UP")
endfunction

should be

Collapse JASS:
private function OnInit takes nothing returns nothing
    local integer i
    
    //! textmacro KeyAction_RegisterEvents takes KEY, DIR
        set i = 0
        loop
            exitwhen i > 11
            
            // The actual event
            call TriggerRegisterPlayerEvent(key_$KEY$_$DIR$, Player(i), EVENT_PLAYER_ARROW_$KEY$_$DIR$)

            set i = i + 1
        endloop

        // For the functions
        call TriggerAddCondition(key_$KEY$_$DIR$, Condition(function HandleKeyEventFunc_$KEY$_$DIR$))
    //! endtextmacro
    
    //! runtextmacro KeyAction_RegisterEvents("UP",    "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("UP",    "UP")
    //! runtextmacro KeyAction_RegisterEvents("DOWN",  "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("DOWN",  "UP")
    //! runtextmacro KeyAction_RegisterEvents("LEFT",  "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("LEFT",  "UP")
    //! runtextmacro KeyAction_RegisterEvents("RIGHT", "DOWN")
    //! runtextmacro KeyAction_RegisterEvents("RIGHT", "UP")
endfunction
it probably wasnt noticed before because it sorta does the same thing in game. well. it calls execute on the same interface 12 times, each time crashing the one before it until it finally runs fully on the 12th, but hey what's it matter if it runs
oh yeah it also means that the initial event (where it sets the key down and all that internal magic) happens 12 times, each time the exact same things being set lol

also i thought id share my findings after using this. the system works great and allows easy access / general use. id definitely recommend this as a prototyping thing ("hmm... is this actually a good idea?") but if you need to react to quick key presses youll need to either make your own system or butcher out the "general" components of this one. by quickpress, i mean >1 second reaction time AND frequent key presses. you should just use this system barring that
Yrth is offline   Reply With Quote