HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Passing local variables across triggers.

01-03-2006, 10:09 AM#1
Moss
I haven't done any map making for a while. I thought when you called one trigger from another the Triggering Unit etc. and local variables were understood by that second trigger but thats not happenning for me now. Am I dreaming? Is there a way to achieve something like that?
01-03-2006, 10:30 AM#2
Earth-Fury
local variables are variables local to a function. "triggering unit", and such, are functions, and not variables at all. calling a new trigger is calling a new function, thus local variables will not be passed to the new trigger, but triggering unit, picked unit, ext. are useable, because they return the value yet they are not variables.
01-05-2006, 12:59 AM#3
johnfn
To answer your question (if you didn't get it), either you can make a global variable and set the global to the local, or turn the trigger into a function and call the function with the local variable as an argument.
01-05-2006, 06:12 AM#4
Blade.dk
Or eventually use the Caster System or the Local Handle Variables to attach the locals to the trigger.
01-05-2006, 09:14 AM#5
Daelin
Umm, I think what Moss is trying to say is that he remembers that calling any function in an execution thread allows the use of Event-Response Units from that thread. For example:

Collapse JASS:
function ManaBurn_Respons takes nothing returns nothing
local unit cast = GetTriggerUnit()
local unit targ = GetSpellTargetUnit()
endfunction

If calling another function within that function, and is in the same thread (you do it with call, and not through timers, triggers, ForGroup or other stuff) then you can access GetTriggerUnit(), and GetSpellTargetUnit() (for the second one as long as no TriggerSleepAction() is called before using it).

If this is the question Moss, then the answer is yes, you can use them by calling them through the same Event-Response Function (GetTriggerUnit(), GetAttacker() and so on). I'll give you an example:

Collapse JASS:
function Check takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer())
endfunction

function Whatever takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(g, GetSpellTargetLoc(), 600.00, Condition(function Check))
endfunction


Yes, all enemy units of the owner of the caster within the specified area willl be added to group g.

~Daelin
01-05-2006, 09:30 AM#6
Blade.dk
Quote:
Originally Posted by Daelin
If calling another function within that function, and is in the same thread (you do it with call, and not through timers, triggers, ForGroup or other stuff) then you can access GetTriggerUnit(), and GetSpellTargetUnit() (for the second one as long as no GetTriggerSleepAction() is called before using it).

Just to avoid trouble, event responces works in ForGroup callbacks, waits just don't.

Anyways, also always remember that some event responces overwrites each other, for example if a trigger calls another trigger GetTriggeringTrigger will be overwritten, or if you have ForGroup calls in ForGroup callbacks GetEnumUnit will be overwritten.
01-05-2006, 10:20 AM#7
Daelin
Yes, I experienced that myself. Thank god I don't have to use ForGroup in ForGroup a lot. ;)

~Daelin
01-05-2006, 12:02 PM#8
Earth-Fury
Quote:
Originally Posted by Daelin
Umm, I think what Moss is trying to say is that he remembers that calling any function in an execution thread allows the use of Event-Response Units from that thread. For example:

JASS:
function ManaBurn_Respons takes nothing returns nothing local unit cast = GetTriggerUnit()
local unit targ = GetSpellTargetUnit()
endfunction


If calling another function within that function, and is in the same thread (you do it with call, and not through timers, triggers, ForGroup or other stuff) then you can access GetTriggerUnit(), and GetSpellTargetUnit() (for the second one as long as no GetTriggerSleepAction() is called before using it).

If this is the question Moss, then the answer is yes, you can use them by calling them through the same Event-Response Function (GetTriggerUnit(), GetAttacker() and so on). I'll give you an example:

JASS:
function Check takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer())
endfunction function Whatever takes nothing returns nothing local group g = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(g, GetSpellTargetLoc(), 600.00, Condition(function Check))
endfunction



Yes, all enemy units of the owner of the caster within the specified area willl be added to group g.

~Daelin

isnt that just a complicated version of what i said? (that oddly enuf, i understood )
01-05-2006, 01:04 PM#9
Starcraftfreak
I just want to add that the function is called TriggerSleepAction and that it takes one real value as argument. There is not GetTriggerSleepAction().
01-05-2006, 01:48 PM#10
Daelin
Quote:
Originally Posted by Starcraftfreak
I just want to add that the function is called TriggerSleepAction and that it takes one real value as argument. There is not GetTriggerSleepAction().

Sorry, was in a hurry when wrote that. And I didn't add a parameter because its value does not matter. The simple use of the function is enough to clear GetSpellTargetUnit().

~Daelin