• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Add Event not working?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
This is not wroking at all, it's not running.

The second trigger, any ideas? :>


  • Gate Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Apartment 1 --------
      • Player Group - Add Player 1 (Red) to GateControl_g[GateCount]
      • Set GateOwner[GateCount] = Player 1 (Red)
      • Set Gate[GateCount] = Gate (Elven) 0067 <gen>
      • Set GatePathing[GateCount] = Gate Blocker 0281 <gen>
      • Set GateFacing[GateCount] = 0.00
      • Custom script: set udg_GateCount = udg_GateCount + 1
      • -------- Apartment 2 --------
      • Set Gate[GateCount] = Gate (Elven) 0066 <gen>
      • Set GatePathing[GateCount] = Gate Blocker 0084 <gen>
      • Set GateFacing[GateCount] = 0.00
      • Set GateFacing[(GateCount + 500)] = 0.85
      • Custom script: set udg_GateCount = udg_GateCount + 1
      • -------- Apartment 3 --------
      • Set Gate[GateCount] = Gate (Elven) 0102 <gen>
      • Set GatePathing[GateCount] = Gate Blocker 0106 <gen>
      • Set GateFacing[GateCount] = 0.00
      • Set GateFacing[(GateCount + 500)] = 0.85
      • Set GateStatus[GateCount] = -2
      • Custom script: set udg_GateCount = udg_GateCount + 1
      • For each (Integer A) from 0 to GateCount, do (Actions)
        • Loop - Actions
          • Destructible - Hide GatePathing[(Integer A)]
          • Custom script: call TriggerRegisterDeathEvent( gg_trg_Gate_Dies, udg_Gate[GetForLoopIndexA()] )

JASS:
function Trig_Gate_Dies_Actions takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > udg_GateCount
        if (GetDyingDestructable() == udg_Gate[i]) then
            call DestructableRestoreLife(udg_Gate[i], 1, true)
            call SetDestructableAnimationBJ( udg_Gate[i], "death")
            call SetDestructableInvulnerableBJ(udg_Gate[i], true)
            call KillDestructable(udg_GatePathing[i])
            //set udg_GateStatus[i] = 0 // GateStatus = Broken
            set i = udg_GateCount + 1 
            else  
            set i = i + 1
        endif
        endloop

endfunction

//===========================================================================
function InitTrig_Gate_Dies takes nothing returns nothing

    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Trig_Gate_Dies_Actions)
    set t = null

endfunction
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
No, the trigger below is a local trigger "t".

"gg_trg_" is added before GUI triggers.

It should be:
JASS:
//===========================================================================
function InitTrig_Gate_Dies takes nothing returns nothing
    gg_trg_Gate_Dies = CreateTrigger()
    call TriggerAddAction(gg_trg_Gate_Dies, function Trig_Gate_Dies_Actions)

endfunction

Right now you're walking a fine line between GUI and JASS, the point where "but it just doesn't work" sets in. I suggest you pick one and stick to it. If its JASS, go read a tutorial on how initializers work.
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
No, the trigger below is a local trigger "t".

"gg_trg_" is added before GUI triggers.

It should be:
JASS:
//===========================================================================
function InitTrig_Gate_Dies takes nothing returns nothing
    gg_trg_Gate_Dies = CreateTrigger()
    call TriggerAddAction(gg_trg_Gate_Dies, function Trig_Gate_Dies_Actions)

endfunction

Right now you're walking a fine line between GUI and JASS, the point where "but it just doesn't work" sets in. I suggest you pick one and stick to it. If its JASS, go read a tutorial on how initializers work.

That was easy... You are probably right.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Making local triggers is fine, but the function that creates the trigger has to be called somewhere.

If you want to go the JASS route, I suggest using vJASS.

Within a scope or library, you can have an initializer function that is automatically run on startup.

e.g.

JASS:
library MyLibrary initializer InitFunc
    function InitFunc takes nothing returns nothing
        //register triggers here
    endfunction
endlibrary
 
Status
Not open for further replies.
Top