-
Notifications
You must be signed in to change notification settings - Fork 0
Create Your Own Modules
Kiki edited this page Dec 25, 2024
·
11 revisions
Creating a module in Scriptor is as simple as creating any script, with just a few differences:
-
No Compilation or Execution Needed:
Modules are passive pieces of code and do not require compilation or execution when created. They are only compiled and executed when
#included in another script. -
No Owner:
Modules do not have an owner until they are included in a script. At that point, they inherit the owner of the script they are#included in.
To create a module, use the scriptor_add_module(...) function (see Module Functions) instead of new Scriptor(...), which you would do, when you create a script.
scriptor_add_module("roll_dice", @"
self.dice_result = roll_dice(6)
");In this example:
- A module named
roll_diceis created. - The result of the roll is stored in the
dice_resultvariable of the owner of the script.
Once created, the module can be included in any script using #include.
#include roll_dice
if self.dice_result == 6 self.combat.opponent.die()In this script:
- The
roll_dicemodule is included and executed. - The result of the dice roll (
self.dice_result) is checked. - If the result is 6, the opponent's
die()method is called.
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