• 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 question

Status
Not open for further replies.
Level 12
Joined
Jan 30, 2009
Messages
1,067
I'm not entirely sure what you are asking?

Are you asking when to start using actions?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The first function that gets run by engine ingame is the "main" function, which you normally do not see in standard editor/JNGP. This main function can run other functions such as the init functions of your triggers. To run something, you can either do a direct call with call function(<params>), a more indirect call via a native function like ForGroup(<group>, <code>) or you set up a trigger with an action block and an event (TriggerRegister...) that gets automatically fired by engine.

Take a look through the functions list or if you used GUI before, convert some stuff.

By default, each trigger leaf that you create in editor gets one "InitTrig_<trigName>" function that is registered for being run by the main function in beginning.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Not directly to the functions but trigger handles.

JASS:
function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function yourFunction) or TriggerAddCondition(t, Condition(function yourFunction))
    call TriggerRegister...(t, ...)
    set t = null
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
Well, i noticed the add action and add condtion can be binded to a function (i think since i cant really read the jass) while the event only be binded to a trigger how do i make the event execute something then? Because i have heard that jass can use multiple events in same trigger so you only need one big trigger for things. if the event you scroll through all functions that wont work
JASS:
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function Trig_Untitled_Trigger_001_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The event fires the trigger and the trigger fires the conditions/actions. If multiple events are registered for a trigger, when any of those events occurs, the trigger will be fired.

Stuffing everything in one trigger would not be so smart. You cannot perfectly differentiate which event occured and checking this would take some performance. Accumulating events on one trigger only makes sense when those events should run about the same conditions/actions.
 
Status
Not open for further replies.
Top