Variable

From ENIGMA
Jump to navigation Jump to search

Variables are generally use for representing data in computer languages. They are used to represent certain things like the number of apples a player has or his current score, locations of objects and other things like that. EDL supports some of the lower levels ones from GML such as the ones below, including regular C++ data types, such as boolean true or false and floating point integer values.

In ENIGMA and Game Maker, variables come in several different flavors:

  • Constant - All objects may read its value. The value never changes. Because of this, a constant isn't technically a variable, but it is included here for completeness.
  • Global - All objects and instances may access and change the variable. If one object changes the variable, other objects will see the new value. Global variables come in three types: predefined, global flagged, and global dot access.
  • Global local - All objects and instances already have these variables defined, but each instance has a local copy. If one instance changes the variable, only that instance will see the new value, while other objects and instances will see their own value.
  • Local - An object may define these variables, but each instance has a local copy. Other objects will not see the value unless they define it themselves or use dot access on the variable. If one instance changes the variable, only that instance will see the new value, while other instances will see their own value.
  • Typed/Scoped - Any variable defined with either the var keyword or any of the data type keywords becomes a scoped variable. At some point, usually at the end of the script or event that the variable is in, the scoped variable will disappear, meaning that other events cannot access it - called losing scope. This is particularly useful in conserving memory - after the variable loses scope, its memory may be recycled for something else. To prevent a typed variable from losing scope, explicitly flag it as local.

Read Only

Various read only variables such as working_directory.