Can map-specific triggers use variables from a library and vice versa?
I have a unit variable array in my library Overseer[4] with Initial Value: No Unit and the map triggers I want to work are as follows
-----
Map Initialization
Event
Map Initialization
Actions
Unit - Create an Overseer for Player 1 at [point]
Variable - Set Overseer[1] = (Last created unit)
Defeat
Event
Unit - Overseer[1] dies
Actions
Game - End game in defeat for Player 1
-----
The goal is for the defeat trigger to execute when Player 1's Overseer dies.
The problem I'm getting is that the defeat trigger executes when Any Unit dies.
I would like to keep the unit variable as an array for consistency's sake. I use this library for multiplayer games.
Events are registered when the map loads. At that time, your initialization trigger has not yet run, so your array is not initialized. As a result, you'r not registering the correct unit. The only way to go around that is to add a piece of custom script code that adds the event from your initilization trigger
If that map initialization trigger is located in a library, it is a little more difficult, since I don't think you will be able to refer to the defeat trigger from there, unless it is also in the same library. If it's outside, make an initialization trigger outside the library, and put the custom script there - events for library triggers are registered before events for non library triggers, so they should run in the proper order.
If your overseer variable is in the library, then the name of the variable changes a bit. Maybe it will be lib1_gv_overseer.. If not, you will have to look for the right name in the custom script code for your library (ctrl+F11).
Events are registered when the map loads. At that time, your initialization trigger has not yet run, so your array is not initialized. As a result, you'r not registering the correct unit. The only way to go around that is to add a piece of custom script code that adds the event from your initilization trigger
If that map initialization trigger is located in a library, it is a little more difficult, since I don't think you will be able to refer to the defeat trigger from there, unless it is also in the same library. If it's outside, make an initialization trigger outside the library, and put the custom script there - events for library triggers are registered before events for non library triggers, so they should run in the proper order.
If your overseer variable is in the library, then the name of the variable changes a bit. Maybe it will be lib1_gv_overseer.. If not, you will have to look for the right name in the custom script code for your library (ctrl+F11).
Would it work if I simply changed the defeat trigger event to "Any Unit Dies" and add a condition "(Triggering Unit) == Overseer[1]?"
Yes.. that would be the simple way to do it :)
The only down side is that such a trigger would execute each time any unit dies. But if you don't have too many threads due to sudden unit deaths, then it's probably not a problem.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Can map-specific triggers use variables from a library and vice versa?
I have a unit variable array in my library Overseer[4] with Initial Value: No Unit and the map triggers I want to work are as follows
-----Map Initialization
Defeat
-----The goal is for the defeat trigger to execute when Player 1's Overseer dies. The problem I'm getting is that the defeat trigger executes when Any Unit dies.
I would like to keep the unit variable as an array for consistency's sake. I use this library for multiplayer games.
Events are registered when the map loads. At that time, your initialization trigger has not yet run, so your array is not initialized. As a result, you'r not registering the correct unit. The only way to go around that is to add a piece of custom script code that adds the event from your initilization trigger
If that map initialization trigger is located in a library, it is a little more difficult, since I don't think you will be able to refer to the defeat trigger from there, unless it is also in the same library. If it's outside, make an initialization trigger outside the library, and put the custom script there - events for library triggers are registered before events for non library triggers, so they should run in the proper order.
If your overseer variable is in the library, then the name of the variable changes a bit. Maybe it will be lib1_gv_overseer.. If not, you will have to look for the right name in the custom script code for your library (ctrl+F11).
Would it work if I simply changed the defeat trigger event to "Any Unit Dies" and add a condition "(Triggering Unit) == Overseer[1]?"
Yes.. that would be the simple way to do it :)
The only down side is that such a trigger would execute each time any unit dies. But if you don't have too many threads due to sudden unit deaths, then it's probably not a problem.