Help with learning jass.

MiddleHanded

New Member
Reaction score
1
1 function InitTrig_HeroRespawn_Copy takes nothing returns nothing
2 set gg_trg_HeroRespawn_Copy = CreateTrigger( )
3 call TriggerRegisterAnyUnitEventBJ( gg_trg_HeroRespawn_Copy, EVENT_PLAYER_UNIT_DEATH )
4 call TriggerAddCondition( gg_trg_HeroRespawn_Copy, Condition( function Trig_HeroRespawn_Copy_Conditions ) )
5 call TriggerAddAction( gg_trg_HeroRespawn_Copy, function Trig_HeroRespawn_Copy_Actions )
6 endfunction

Could someone explain to me step by step the actions this jass script does?
 

Executor

I see you
Reaction score
57
First of all, a "trigger" in Jass is an object consisting of conditions and actions. You may register a trigger to events, so the trigger "fires" when the event "fires" (an event is for example "a unit dies").
When a trigger fires, it first of all evaluates each condition and if all return true all actions are fired. But it is unusual to add more than one condition or action.

1 function InitTrig_HeroRespawn_Copy takes nothing returns nothing
2 set gg_trg_HeroRespawn_Copy = CreateTrigger( )
3 call TriggerRegisterAnyUnitEventBJ( gg_trg_HeroRespawn_Copy, EVENT_PLAYER_UNIT_DEATH )
4 call TriggerAddCondition( gg_trg_HeroRespawn_Copy, Condition( function Trig_HeroRespawn_Copy_Conditions ) )
5 call TriggerAddAction( gg_trg_HeroRespawn_Copy, function Trig_HeroRespawn_Copy_Actions )
6 endfunction

  1. function InitTrig_NameOfTheGUITrigger is a function which fires on map initialization
  2. gg_trg_HeroRespawn_Copy is a variable generated by the world editor and it is set to a new trigger
  3. the new trigger gets registered to the "any unit dies" event
  4. a condition is added to the trigger
  5. an action is added to the trigger
  6. end of the function InitTrig
 

Komaqtion

You can change this now in User CP.
Reaction score
469
1. This is the function which fires on Map Initialization, and it's always (Usually at least :p) here you create the trigger, and register events and actions/conditions :D

2. With this little line you create a trigger (On which the events/actions/conditions is attached) on a pre-created global trigger variable, which the World Editor automatically creates when you create a new trigger in the Trigger Editor...
Usually you don't even use this, as a local trigger variable is normally only needed, and also if you do use the global trigger, you can't rename the trigger inside the Trigger Editor ;)

3. This registers the "GUI" event "Unit - A unit Dies" ([ljass]EVENT_PLAYER_UNIT_DEATH[/ljass]) to the trigger gg_trg_HeroRespawn_Copy :D

4. This add a condition to the trigger, which the trigger will check before going on with the actions.
The condition is in the form of another function, which returns a boolean, false if the unit doesn't match the condition (Then the actions won't run) and true if it does (And the actions will run).
In this case, the condition function's name is "Trig_HeroRespawn_Copy_Conditions" ;)

5. This will simply add an actions (Yet again, in the form of a function) to the trigger, which will run when the event fires, and the condition returns true :D

6. This is simply an ending to that particular function, meaning that anything after it won't run on Map Initialization (In this case) :D

Hope this helps, and good luck with learning JASS :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top