Local
Jump to navigation
Jump to search
A local variable only exists within the scope it is specified. The scope is the 'level' it is visible for the script and thus readable and editable.
Usage
You should use local variables anytime it is possible, when you don't need to access them globally. This saves you from having troubles with duplicate variable names.
Examples
function showMoney(source) local playermoney = getPlayerMoney ( source ) outputChatBox(playermoney) end
The playermoney variable only exists within the 'showMoney' function.
outputChatBox("This is your status:",player) if (showHealth == true) then local health = getPlayerHealth(player) outputChatBox("Heahlth: "..health,player) end
The health variable only exists within the if-condition block, that is between the 'then' and the 'end'.