1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Multiple events

Discussion in 'World Editor Help Zone' started by Kamulec, May 19, 2013.

  1. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Trigger "LeavingArea" is complexed. It compiles so I paste only the Init function because I want to ask about it.

    Code (vJASS):
    function InitTrig_LeavingArea takes nothing returns nothing

        set gg_trg_LeavingArea = CreateTrigger(  )

        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 107
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call TriggerRegisterLeaveRectSimple( gg_trg_LeavingArea, udg_Area_Region[GetForLoopIndexA()])
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call TriggerAddAction( gg_trg_LeavingArea, function Trig_LeavingArea_Actions )

    endfunction


    Problem:
    Trigger doesn't run when one of events occurs. I have used
    Code (vJASS):
    call DisplayTimedTextToForce( bj_FORCE_PLAYER[0], 120.00, [test string] )
    to test it. It clearly shows Trig_LeavingArea_Actions is not executed.

    Question:
    Why it doesn't work/how to fix?
     
  2. gorillabull

    gorillabull

    Joined:
    Jul 17, 2011
    Messages:
    1,365
    Resources:
    2
    Spells:
    2
    Resources:
    2
    make sure the region variable is assigned to a region.
    also if you are going to use jass you should use locals, replace forloopindexa and forloopaindexend with local integer something
    also make sure test string has some text in it
     
  3. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Can it cause errors in this case?


    gg_trg_Group_Buildings include call TriggerExecute(gg_trg_Group_Buildings_Plus). These two triggers initialise variables. I have removed event from gg_trg_Group_Buildings and added TriggerExecute to the code (pasted below). The trigger is still not working.

    Code (vJASS):
    function InitTrig_LeavingArea takes nothing returns nothing

        set gg_trg_LeavingArea = CreateTrigger(  )
        call TriggerExecute( gg_trg_Group_Buildings )
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 107
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call TriggerRegisterLeaveRectSimple( gg_trg_LeavingArea, udg_Area_Region[GetForLoopIndexA()])
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call TriggerAddAction( gg_trg_LeavingArea, function Trig_LeavingArea_Actions )
    endfunction
     
  4. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Cease help, I have probably found the solution. Tests needed.

    If you can please answer on question about the loop A.
     
    Last edited: May 19, 2013
  5. gorillabull

    gorillabull

    Joined:
    Jul 17, 2011
    Messages:
    1,365
    Resources:
    2
    Spells:
    2
    Resources:
    2
    no it cant cause errors unless you call another loop which reassigns those 2 integers different values, its just more convenient to use locals in this case
     
  6. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Not solved. The problem is gg_trg_Group_Buildings (variable initialization) is executed after the loop (DisplayTimedTextToForce displays zeros). How can I fix that?

    Code (vJASS):
    function InitTrig_LeavingArea takes nothing returns nothing
        local integer i = 1
        set gg_trg_LeavingArea = CreateTrigger(  )
        call TriggerExecute( gg_trg_Group_Buildings )
        loop
            exitwhen i > udg_NumberOfTowns
            call TriggerRegisterLeaveRectSimple( gg_trg_LeavingArea, udg_Area_Region[i])
            call DisplayTimedTextToForce( bj_FORCE_PLAYER[0], 120.00, R2S(GetRectCenterX(udg_Area_Region[i])) )
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call TriggerAddAction( gg_trg_LeavingArea, function Trig_LeavingArea_Actions )
    endfunction


    NumberOfTowns has a default value = 107.
     
  7. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0
    You use i in that trigger bu increment bj_forLoopIndexA
     
  8. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Another issue might be, as gorillabull said, that your rects haven't been defined yet. To fix this, change the code to:
    Code (vJASS):
    function LeavingArea_onStart takes nothing returns nothing
        local integer i = 1
        call DestroyTimer(GetExpiredTimer())
        set gg_trg_LeavingArea = CreateTrigger(  )
        call TriggerExecute( gg_trg_Group_Buildings )
        loop
            exitwhen i > udg_NumberOfTowns
            call TriggerRegisterLeaveRectSimple( gg_trg_LeavingArea, udg_Area_Region[i])
            call DisplayTimedTextToForce( bj_FORCE_PLAYER[0], 120.00, R2S(GetRectCenterX(udg_Area_Region[i])) )
            set i = i + 1 // fixed it as Arhowk said
        endloop
        call TriggerAddAction( gg_trg_LeavingArea, function Trig_LeavingArea_Actions )
    endfunction

    function InitTrig_LeavingArea takes nothing returns nothing
        call TimerStart(CreateTimer(), 0, false, function LeavingArea_onStart)
    endfunction


    That way it will wait for the game to start before doing its actions instead of during initialization (where some things might not have been defined yet).
     
  9. Kamulec

    Kamulec

    Joined:
    May 15, 2008
    Messages:
    104
    Resources:
    1
    Maps:
    1
    Resources:
    1
    For now I run gg_trg_Group_Buildings at map initialization, and I do not call it from this function. With this modification, your solution works. Thanks to both of you.