Difference between revisions of "HPL3/Scripting/Scripting Guide/Local and Global Variables"
(Created page with "{{Hpl3ScriptingGuideMenuBasic}} {{shortPageTitle}} Local and global variables are variables that have a certain scope compared to the script in which it is located in. There...") |
m (TiMan moved page HPL3/Scripting/Local and Global Variables to HPL3/Scripting/Scripting Guide/Local and Global Variables) |
(No difference)
|
Revision as of 12:57, 13 August 2020
Local and global variables are variables that have a certain scope compared to the script in which it is located in.
There are certain levels of scope to a script, there is the function's scope, then there is the local scope, then there is the global scope.
A function's scope consists of everything within its braces ({ }). Normal variables as shown above will only work in a function unless carried over to another function.
A local variable's scope is the whole entire script, so if you made a local variable, then you wouldn't have to worry about having to carry it over from function to function. The downside to it is that you can't use the value of the local variable in commands. It is mostly used to check and see if the player has done multiple things within the map to make something greater happen.
To do: Add code example more explanation about scopes