• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] Trigger Causes Crash

Status
Not open for further replies.
Level 10
Joined
Sep 21, 2007
Messages
517
It just registers Arrow Key events to local triggers, so dont understand why... here is code:

JASS:
library ArrowKeyCore initializer Init

    globals
        private constant real MoveDist = 600
        boolean array bKeyUp[11]
        boolean array bKeyDown[11]
        boolean array bKeyRight[11]
        boolean array bKeyLeft[11]
    endglobals
    
    //Key Press Actions
    function AKeyUp takes nothing returns nothing
        //local player p = GetTriggerPlayer()
        set bKeyUp[GetPlayerId(GetTriggerPlayer())] = true
        //call MoveOffset( udg_PlayerHero[GetPlayerId(p)+1], MoveDist, GetUnitFacing(udg_PlayerHero[GetPlayerId(p)+1] )
        //set p = null
    endfunction
    function AKeyDown takes nothing returns nothing
        set bKeyDown[GetPlayerId(GetTriggerPlayer())] = true
    endfunction
    function AKeyLeft takes nothing returns nothing
        set bKeyLeft[GetPlayerId(GetTriggerPlayer())] = true
    endfunction
    function AKeyRight takes nothing returns nothing
        set bKeyRight[GetPlayerId(GetTriggerPlayer())] = true
    endfunction
    // Key Release Actions
    function RKeyUp takes nothing returns nothing
        set bKeyUp[GetPlayerId(GetTriggerPlayer())] = false
    endfunction
    function RKeyDown takes nothing returns nothing
        set bKeyDown[GetPlayerId(GetTriggerPlayer())] = false
    endfunction
    function RKeyLeft takes nothing returns nothing
        set bKeyLeft[GetPlayerId(GetTriggerPlayer())] = false
    endfunction
    function RKeyRight takes nothing returns nothing
        set bKeyRight[GetPlayerId(GetTriggerPlayer())] = false
    endfunction
    //===================================================
    private function Init takes nothing returns nothing
        local trigger KeyUpPress = CreateTrigger( )
        local trigger KeyDownPress = CreateTrigger( )
        local trigger KeyRightPress = CreateTrigger( )
        local trigger KeyLeftPress = CreateTrigger( )
        //
        local trigger KeyUpRelease = CreateTrigger( )
        local trigger KeyDownRelease = CreateTrigger( )
        local trigger KeyRightRelease = CreateTrigger( )
        local trigger KeyLeftRelease = CreateTrigger( )
        //**************************************
        local integer i = 0
        loop
            exitwhen i == 11
            if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
                call TriggerRegisterPlayerKeyEventBJ( KeyUpPress, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
                call TriggerRegisterPlayerKeyEventBJ( KeyDownPress, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
                call TriggerRegisterPlayerKeyEventBJ( KeyRightPress, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
                call TriggerRegisterPlayerKeyEventBJ( KeyLeftPress, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
                //
                call TriggerRegisterPlayerKeyEventBJ( KeyUpRelease, Player(i), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_UP )
                call TriggerRegisterPlayerKeyEventBJ( KeyDownRelease, Player(i), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_DOWN )
                call TriggerRegisterPlayerKeyEventBJ( KeyRightRelease, Player(i), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_RIGHT )
                call TriggerRegisterPlayerKeyEventBJ( KeyLeftRelease, Player(i), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_LEFT )
            endif
            set i = i + 1
        endloop
        call TriggerAddAction(KeyUpPress, function AKeyUp)
        call TriggerAddAction(KeyDownPress, function AKeyDown)
        call TriggerAddAction(KeyRightPress, function AKeyRight)
        call TriggerAddAction(KeyLeftPress, function AKeyLeft)
        //
        call TriggerAddAction(KeyUpRelease, function RKeyUp)
        call TriggerAddAction(KeyDownRelease, function RKeyDown)
        call TriggerAddAction(KeyRightRelease, function RKeyRight)
        call TriggerAddAction(KeyLeftRelease, function RKeyLeft)
    endfunction

endlibrary

rep to help ofc ^^
 
Level 4
Joined
Apr 16, 2009
Messages
85
copy pasted into a clean map -> didn't crash so i guess its something else (eg. another trigger or an outdated jasshelper version)
 
Status
Not open for further replies.
Top