Modules
Hybrix modules help you to organize your code. A module can contain variables (defined using VAR) and functions (defined using FUNC). The VAR definitions must always go at the top, before any FUNC definitions.
The example below defines two modules, named STATUS and MAIN:
MODULE STATUS
# (VARIABLES MUST ALWAYS COME FIRST, BEFORE ANY FUNCS)
VAR FOUND_TREASURE_CHEST: BOOL
VAR COINS: INT
FUNC INIT()
FALSE -> STATUS::FOUND_TREASURE_CHEST
0 -> COINS
END FUNC
FUNC COLLECT_COIN()
STATUS::COINS + 1 -> STATUS::COINS
END FUNC
END MODULE
MODULE MAIN
FUNC START()
STATUS::INIT()
# ACCESS A VARIABLE
TRUE -> STATUS::FOUND_TREASURE_CHEST
# CALL A FUNCTION
STATUS::COLLECT_COIN()
END FUNC
END MODULE
Unlike a class, a module has only one instance; the SELF variable does not exist inside a module. In computer science terminology, module variables are "global variables," and module functions are "static functions".
When accessing to members of a module, you must always include the module name using ::. For example, we must write STATUS::FOUND_TREASURE_CHEST (not FOUND_TREASURE_CHEST) and STATUS::COLLECT_COIN() (not COLLECT_COIN()).