-
Notifications
You must be signed in to change notification settings - Fork 0
reset
For performance reasons, the script variables of a script are not reset between runs by default. This can become very handy, if you want to do things in your scripts (like counting things) over several executions of a script.
It can, however, be necessary to reset everything to default now and then. Normally, there's no reason to do this, but if you need it, the reset command will do exactly that.
A simple, straightforward command without any parameters.
resetreset can not simply set the internal variable store to {}, because that would create an entirely new struct to store the variables. Especially in conjunction with the call command, this could break pointers, shared variables would no longer work.
Therefore, the reset command must take a "soft" approach of cleaning the variables of a script. What this command internally does is:
var names = struct_get_names(_exe.vars);
for (var i = 0, len = array_length(names); i < len; i++)
struct_remove(_exe.vars, names[@i]);It removes all known variables from the internal store, one by one in a loop. This is the only way to ensure, all pointers stay intact, as no new instance of a struct is generated. It has the drawback of impacting performance, therefore:
Caution
Due to the requirement of preserving existing pointers, the reset command is quite slow and can impact performance.
Use it only, when you really have to!
The better approach would be to design your scripts in a way, where a reset is never necessary!
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