Menu

Scope

Hugh Greene

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 var keyword or a
    C++ type. This scope can be referred to via dot
    access
    using the local keyword.
  • The local scope refers to variables that are local to the current
    instance, such as my_health or my_life. These also include
    built-in instance variables such as x, y, hspeed, vspeed,
    alarm, etc. This scope can be referred to via dot
    access
    using the self keyword.
  • 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 the local
    keyword. This scope is also referred to using the local
    keyword.
  • The global scope is a single scope which can be referenced by all
    objects. This scope has two categories.
    1. 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 using globalvar, or the global keyword
      followed by a C++ type name.
    2. The explicit global scope contains variables you assign using
      dot access with the global
      keyword.

Related

Wiki: Variable

MongoDB Logo MongoDB