Quote from SouLCarveRR: Go
I think he needs a brief introduction in to what "scope" is and how it relates to Global and local variables as well.....
Try googling.... "Global Variable" and "Local variable" You will find a wealth of knowledge. This is basic programing stuffs, its pretty educational.
Scope is very important when programming. SC2 Galixy Scope does not differ that much really.
Scope is a way of managing what can be seen from any point in code. Global variables that are created outside of a trigger are visible to all triggers. A local variable created within a trigger is only visible with the trigger, and when the trigger is finished, the variable is destroyed.
The variable being destroyed when the trigger is finished it a good thing. Knowing this means that we need to decide at any point when a variable needs to be global, or when it should be local to the trigger.
Let’s say you were keeping score. And you have a trigger that adds points to a players score. It would be bad to create the scoring variable local to the trigger. If we did, the score would be created, the points added, and then the score variable would be deleted. The next time the trigger tries to add points to the score, it would start over, and again delete the score. If we did the same scenario with global variable for score. The trigger would start, it would add points to the score, and then the trigger would destroy itself when done. But our global variable of score is still intact outside of the trigger.
Let’s take this example and include both global and local variable for score. First we have a global variable that is the total score. Then a trigger fires to add points to the score. It creates a local variable for adding up points. A number of math routines add numbers to the local variable based on how many units were killed, and what type of unit is worth how many points. After the score for the trigger adding the points has work out its total. It then adds that local variables value of kill total, to the global variable of total score. The trigger finishes and destroys the local kill total variable before exiting. The players total score as a global variable is left intact.
Back to the topic of scope, a trigger can see(Scope) any variables that are global. A trigger cannot see variables that are local to other triggers. So the scope for any trigger is itself and global.
Without going off topic into ways of sharing other triggers local variable values with other triggers. You should be able to make your map without using those techniques. When you understand these concepts, you can start to look for functions, parameters and such.
Cheers, ItsAboutTime: Sldprt