That's a specific unit event, unfortunately you cannot choose a Variable in these Events.
However, there is a workaround. You can add Events to your triggers via actions. Here's an example of creating a Footman, storing it as a UNIT Variable, and adding that unit to the Events to the Comes Within Range trigger.
Note that there can be some limitations with this method, as I've seen people run into issues where they added 100's of units to Events this way and eventually the trigger stopped working. However, that may not be the case here.
Actions
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Set VariableSet YourUnit = (Last created unit)
Trigger - Add to RangeTrigger <gen> the event (Unit - A unit comes within 256.00 of YourUnit)
Hello there.
Completing @Uncle 's suggestion, I would advise you to use a trigger array.
Thats right, rather than adding all your unit specific events to a trigger, just create a similar trigger for each unit, and store it in an array.
This way, if anything happens to your unit, like death or anything else that would make the trigger not useful anymore, you will be able to disable the trigger and then alleviate the game engine a bit.
Now reading your last message, if only 1 unit needs to trigger the event, thats even easier with a trigger array ; you only activate the trigger related to your unit.
Of course, to make this practical, make sure the unit and its trigger share the same index![]()
Well @Uncle : I was investigating these GUI triggers giving me headaches everytime I try to help someone.
The issue is you can't seem to be able to add trigger actions with the trigger editor in GUI !!!
But I found a workaround :
First he needs to create his unit array and assign the units to the array. I called the array MyUnit for this test.
Then I created a trigger array called MyUnitTrig.
Then create a trigger with no events and no conditions called for example "ChangeColor"
Then give this trigger an action :
Note that this will create a function called "Trig_ChangeColor_Actions" that we can use in the main trigger
ChangeColor
Events
Conditions
Actions
Animation - Change MyUnit[(Integer A)]'s vertex coloring to (100.00%, 85.00%, 85.00%) with 85.00% transparency
Now here is the main trigger to create the 44 triggers for the 44 units:
The custom script line allows to add the function Trig_ChangeColor_Actions to the actions of each trigger MyUnitTrig with the same index as MyUnit.
RangeColor
Events
Map initialization
Conditions
Actions
For each (Integer A) from 1 to 44, do (Actions)
Loop - Actions
Trigger - Add to MyUnitTrig[(Integer A)] the event (Unit - A unit comes within 800.00 of MyUnit[(Integer A)])
Custom script: call TriggerAddAction( udg_MyUnitTrig[GetForLoopIndexA()], function Trig_ChangeColor_Actions )
Trigger - Turn off MyUnitTrig[(Integer A)]
Of course I disable the triggers once created, so every time the trigger for a unit needs to be activate, he will just need toi use Trigger- Turn on MyUnitTrig[*index of the unit*]
That seems much easier this way, doesn't it ?
Hehe I know I like to cheat a bit ;-)
Wait, have you created the trigger with just the action before the other one ?
Edit: Try "gg_trg_Trig_ChangeColor_Actions"
Edit: Try "gg_trg_Trig_ChangeColor_Actions"
function Trig_test_Actions takes nothing returns nothing
call CameraSetupApplyForPlayer( true, GetCurrentCameraSetup(), Player(0), 0 )
endfunction
//===========================================================================
function InitTrig_test takes nothing returns nothing
set gg_trg_test = CreateTrigger( )
call TriggerAddAction( gg_trg_test, function Trig_test_Actions )
endfunction
I don't see the other trigger just before the main one in your log.Check my updated msg![]()
No that does not work and this function does not exist.
I don't have the trigger i made earlier, but let's test it with a simple one :
Once converted to custom text it becomes
test
Events
Conditions
Actions
Camera - Apply (Current camera) for Player 1 (Red) over 0.00 seconds
JASS:function Trig_test_Actions takes nothing returns nothing call CameraSetupApplyForPlayer( true, GetCurrentCameraSetup(), Player(0), 0 ) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction
What we'd want to access there is the function Trig_test_Actions.
And gg_trg_test_Actions does not exist.
I don't see the other trigger just before the main one in your log.
Can you please put the trigger "ChangeColor" just before your trigger "SpawnTiles" and show me the error again ?
Reason is, just looking at the script in your error log shows me that it can not "not work" ^^
Well this time it is MY fault :-D
In "Animation - Change MyUnit[(Integer A)]'s vertex coloring to (100.00%, 85.00%, 85.00%) with 85.00% transparency"
replace MyUnit[(Integer A)] with Triggering unit![]()
I see that you're using 2 Map Initialization triggers, could it be that declareRegions is happening after spawnTiles? Try combining the two triggers or running spawnTiles using an Elapsed Time 0.00 Event.