scope - hpgDesigns/hpgdesigns-dev.io GitHub Wiki
In programming in general, scope refers to the location in which a variable, function, or other object is declared. When referring to scopes in ENIGMA, we usually divide these into five categories, listed below in the order they are checked:
- The script-local scope refers to variables declared explicitly in
the current script or piece of code using the
varkeyword or a C++ type. This scope can be referred to via dot access using thelocalkeyword. - The local scope refers to variables that are local to the current
instance, such as
my_healthormy_life. These also include built-in instance variables such asx,y,hspeed,vspeed,alarm, etc. This scope can be referred to via dot access using theselfkeyword. - The global-local scope is a more precise term for the built-in
instance variables (
x,y,hspeed,vspeed,alarm, ...). This scope does not actually exist in the same sense as other scopes here; it is more of a classification. This scope can be referred to via dot access using thelocalkeyword. This scope is also referred to using thelocalkeyword. - The global scope is a single scope which can be referenced by all
objects. This scope has two categories.
- The implicit global scope contains variables like
room,health,score,lives,mouse_x... These variables can be referred to implicitly, just by name. This scope also includes variables declared usingglobalvar, or the global keyword followed by a C++ type name. - The explicit global scope contains variables you assign using
dot access with the
globalkeyword.
- The implicit global scope contains variables like