Using "Triggering Unit" in event-less triggers

Pahl

New Member
Reaction score
7
I think this has worked for me before, or atleast "triggering player" has.
But is it possible and always safe to use "triggering unit" in a trigger that isn't the trigger triggered by the event?
Meaning a trigger that runs through "Triggers - Run trigger" in the original trigger?

(A lot of trigger and triggering there, but i hope it makes sense...)
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
set the triggering unit(s) to a global variable (variable for GUI users) and use this instead of triggering unit.
 

Pahl

New Member
Reaction score
7
Well... that wasn't really what i asked, besides it woulden't work in my map since it would be overwritten by other triggers(or the same one).

So what im asking is, is there any strong reason not to use it? like does it always work? (Does it work at all, haven't tested it yet)
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
There won't be a triggering unit in a trigger with no event. Set the triggering unit to a variable and use that everywhere for that unit instead of triggering unit, plus it gets rid of memory leaks.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> "Triggers - Run trigger"

This calls the "actions" function of that trigger.
Which is the same as calling any other function, so any event response that works in the actual trigger will also work in the called one.


Event:
- A unit dies
Conditions:
Actions:
- Trigger - Run "trigger 2"

Event:
Conditions:
Actions:
- Game - Display to (all players) the text: Name of (Dying unit)
 

Pahl

New Member
Reaction score
7
Acctually...
I thought i had done this with triggering player, so i tried it. And it does work.

Code:
Untitled Trigger 003
    Events
        Unit - A unit Is issued an order targeting a point
    Conditions
        (Issued order) Equal to (Order(move))
    Actions
        Trigger - Run Untitled Trigger 004 <gen> (ignoring conditions)
Code:
Untitled Trigger 004
    Events
    Conditions
    Actions
        Game - Display to (All players) the text: (String((Unit-type of (Triggering unit))))

Gives the name of the unit ordered to move.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
"Triggering unit" doesn't leak anything.

> do all 2-hand calls like that leak.

:D

The usual leak rules apply.
Calling a function is nothing to worry about.
 
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