• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Trigger is not executed, does not work

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Hey guys,

i got this trigger. I want it to create, when executed, simply 4 units in 3 random rectangles.

I tried to add a Debugg-Message, and this Jass-Trigger isnt even executed, because the Message isnt shown at the screen.

Can you help me?

JASS:
function Hirsche_Check takes nothing returns boolean
local unit U = GetEnumUnit()
if GetUnitTypeId(U) == 'nder' or GetUnitTypeId(U) == 'n007' then
     set U = null
     return true
endif
     set U = null
     return false     
endfunction

function Hirsche_Spawn_Actions takes nothing returns nothing
    local location array SpawnRects
    local integer random = GetRandomInt(0,2)
    local group Hirsche = CreateGroup()
    call GroupEnumUnitsInRect(Hirsche, GetPlayableMapRect(), Condition(function Hirsche_Check))
    set SpawnRects[0] = Location(GetRectCenterX(gg_rct_1),GetRectCenterY(gg_rct_1))
    set SpawnRects[1] = Location(GetRectCenterX(gg_rct_2),GetRectCenterY(gg_rct_2))
    set SpawnRects[2] = Location(GetRectCenterX(gg_rct_3),GetRectCenterY(gg_rct_3))
    // Zuviele Hirsche?
    if CountUnitsInGroup(Hirsche) < 50 then
          call CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE),'hf00',SpawnRects[random],270.00)
          set random = GetRandomInt(0,2)
          call CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE),'nder',SpawnRects[random],270.00)
          set random = GetRandomInt(0,2)
          call CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE),'nder',SpawnRects[random],270.00)
          // Goldhirsch
          set random = GetRandomInt(0,2)
          call CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE),'hfoo',SpawnRects[random],270.00)
    endif
  // i put the test message here, it does not getting executed!
  // reset
  call RemoveLocation(SpawnRects[0])
  call RemoveLocation(SpawnRects[1])
  call RemoveLocation(SpawnRects[2])
  set SpawnRects[0] = null
  set SpawnRects[1] = null
  set SpawnRects[2] = null
  call DestroyGroup(Hirsche)
  set Hirsche = null      
endfunction

//==== Init Trigger Hirsche Spawn ====
function InitTrig_Hirsche_Spawn takes nothing returns nothing
    local trigger Hirsche_Spawn = CreateTrigger()
    call TriggerAddAction(Hirsche_Spawn, function Hirsche_Spawn_Actions)
    set Hirsche_Spawn = null
endfunction

Thanks in advance,

Emm-A-
 
Uh.. if you are executing a trigger with a function or w/e, then you don't need an event for that trigger.. ><

And why do you need it to be a trigger anyways ><, lol...

It looks like you could just call the function. I don't see a need to make it a trigger : ).

Another thing, here's the issue. Right now, you have it setup so that it just creates the trigger but doesn't actually execute it. If you're going to do this, you need to create it as a permanent trigger so that you can execute it later on, otherwise you won't be able to access it. This is why I'm saying you should just change it into a function.

This has nothing to do with putting an event in : )
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
thanks guys, i will try this.

It has to be a trigger because its only a part of the function. Maybe, when the map is complete, i return this to a function.

@Nestharus:

I made it as an permanent trigger now, i mean i just converted a regular trigger in WE and filled in my code...

@Marcelo:

hm its strange, but i changed GetEnum with GetFilter but nothing happens....

Any other tipps?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You can not reference the trigger, as you used a local for it and never set a global to it.

Thus your are running the wrong trigger, if you are even running a trigger at all.

You have to set your main trigger to a global and then run that trigger from that global variable.
 
You can not reference the trigger, as you used a local for it and never set a global to it.

Thus your are running the wrong trigger, if you are even running a trigger at all.

You have to set your main trigger to a global and then run that trigger from that global variable.

I already brought that up and he said he fixed that issue. ><

Another thing, here's the issue. Right now, you have it setup so that it just creates the trigger but doesn't actually execute it. If you're going to do this, you need to create it as a permanent trigger so that you can execute it later on, otherwise you won't be able to access it. This is why I'm saying you should just change it into a function.

Permanent as in global
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
ok, i tried putting null, no result

And I didnt understand, that you meant global = permanent.

And this was the exact problem.
So it works now.

THANKS TO YOU ALL

But its strange, as i normaly create alle triggers as locals like this, and they all work oO

Greetings
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Triggers work fine with locals if they include the events that run them being attached to the trigger. However if you make triggers with locals you can not modify the trigger once it was created (or run it from another trigger).

Also, since this trigger you used had no event, may I recommed you to make it a function, in which case you simply execute or call it. This would be more efficent than running it via a trigger.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Triggers work fine with locals if they include the events that run them being attached to the trigger. However if you make triggers with locals you can not modify the trigger once it was created (or run it from another trigger).
Good to know, i realldy didnt, so i will pay attention from now on.

Also, since this trigger you used had no event, may I recommed you to make it a function, in which case you simply execute or call it. This would be more efficent than running it via a trigger.

Yeah, maybe i will :)

Thanks, i cant rep you, because it says, i have to gather some first, so i only can write: Thank you ^^
 
Status
Not open for further replies.
Top