-
Couldn't load subscription status.
- Fork 0
Module Functions
Modules in Scriptor operate outside of individual scripts and become globally available once added. They provide a flexible way to reuse code efficiently across your project.
In short terms, a module is any script or part of a script that you want to reuse.
Including a module in your script works similarly to the event_inherited() function of gml. However, it is not a traditional function call. Instead, the source code of the base event will be copied at the position, where event_inherited() resides.
1. Performance Efficiency:
Unlike deep inheritance structures in GML, where constructor chains might reduce performance, module inclusion incurs no runtime cost. Regardless of how complex your inheritance hierarchy is, the event code remains a single function without nested calls.
2. Compile-Time Inclusion:
The #include statement works at compile time, meaning the module's code is inserted directly into the script during compilation. This ensures seamless rebinding and recompilation.
#include your_moduleThe `#include´ statement places the content of the specified module exactly at its location in the script. You can include anything, from a single line of code to an entire sequence, as a module.
Modules are managed using global functions, eliminating the need for instantiating classes. Below are the available functions for working with modules:
/// @func scriptor_add_module(_name, _source_code)
/// @desc If a module with the specified name already exists, it is overwritten
function scriptor_add_module(_name, _source_code) {/// @func scriptor_remove_module(_name)
/// @desc Delete a module. If the specified module does not exist, this is silently ignored
function scriptor_remove_module(_name) {/// @func scriptor_module_exists(_name)
/// @desc Query existance of a module. Returns bool.
function scriptor_module_exists(_name) {Back to Repo ● Wiki Home
Copyright © coldrock.games
- Home
- Scriptor Contents
- Scriptor Configuration
- Notepad⁺⁺ Integration
- Create a Script
- $ Variables
- Call a GML Function
- Scriptor global functions
- #-Commands
- The Scriptor Broker
- Broker Events
- Self-Registering Scripts
- Registering Broker Events
- Scriptor Broker File Format
- Extending Scriptor
- var
- new
- goto
- gosub and return
- return (without gosub)
- call
- reset
- Loops
- Conditionals