-
Notifications
You must be signed in to change notification settings - Fork 0
Assignments
An assignment statement is any operation that assigns a value to a target.
This can range from a simple variable assignment, such as var x = 25, to more complex expressions like alive = (enemy.hp > 0 || enemy.immortal). In all cases, an assignment statement is characterized by the presence of an equals sign = as its second word.
While the expression evaluation engine in scriptor is superior, we face some limitations on assignments in favor to parser complexity and performance.
Scriptor allows you to assign any value to a variable, supporting simple and complex expressions. For Example:
// Assigning values to variables
self.x = 100
self.y = 2 * x + self.sprite_xoffset * ROOMCONTROLLER.camera_zoom
// Variable assignments
myvar = 25
// Array assignments
my_array = []
my_array = [1,2,3,4]
// Struct assignments
my_struct = {}
my_struct.my_val = 25Everything on the right-hand side of the equals sign = is processed by Scriptor's expression evaluation engine, allowing for highly complex expressions.
However, there are limitations on the left-hand side (the receiving part) when it comes to array assignments.
You cannot directly assign a value to a specific index of an array using the bracket notation []. This is a deliberate restriction to prioritize performance and reduce parser complexity.
my_array[4] = 25 // This does NOT work!Instead of direct indexing, use the array_set function:
array_set(my_array, 4, 25) Scriptor provides the most important GML array functions out-of-the-box for managing arrays:
array_pop
array_push
array_shift
array_get
array_set
array_first
array_last
array_length
These functions allow for flexible and performant array manipulation without compromising the efficiency of the parser.
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