System
This module provides functions to interact with the operating system. It contains functions to get screen information, manipulate the garbage collector, and open URLs in the default browser.
Handled structures
- GenericCommand
This struct represents a generic command in the command buffer. It allows to iterate over the commands in the buffer.
- Fields:
hash : uint64
size : uint
- CommandBuffer
This class represents a buffer of commands that can be written to and read from. It is designed for interacting with input, physics events, and similar systems.
Function annotations
- cheat
The [cheat] annotation marks a top-level function as a console-invokable cheat/command.
Cheats are registered at startup and can be called from the in-game console.
This is useful for quick debugging, spawning test data, toggles, and developer tools.
Most basic dasLang types are supported as function parameters (int, float (or double), bool, string, float2, float3, etc)
Any registered cheat can also be invoked from code using the exec_cheat function.
Note
If the optional name parameter is omitted, the function identifier is used as the cheat name.
Use a dotted custom name (for example game.restart) to group cheats or avoid name collisions.
Example of registering cheats:
[cheat]
def restart(level : int = 1) {
createLevel(level)
}
[cheat(name="game.reset_best_scores")]
def reset_best_scores_cheat() {
remove_storage(STORAGE_KEY)
}
Functions
- get_target_fps(): float
- Returns:
float - the target frame rate of the user script execution
- set_target_fps(value: float): float
Sets the target frame rate of the user script execution. Value are clamped to the range [0.0, 1000.0] and the new target frame rate is returned. If the value is set to 0.0, the target frame rate is unlimited.
- Arguments:
value : float - frames per second which will be set
- Returns:
float - the new target frame rate
- get_resolution(): int2
- Returns:
int2 - the resolution of the screen as (x, y) coordinates
- open_url(url: string implicit): bool
Opens a given URL in the default browser of the operating system
- Arguments:
url : string implicit - the URL to be opened
- Returns:
bool - true if the URL was successfully opened, false otherwise
- warning(text: string implicit)
prints the provided line to console, marking it as a warning
- Arguments:
text : string implicit
- print(text: string implicit)
prints the provided line to console
- Arguments:
text : string implicit
- error(text: string implicit)
prints the provided line to console, marking it as an error
- Arguments:
text : string implicit
Mouse cursor functions
- show_mouse_cursor(show: bool = true)
Shows or hides the mouse cursor based on the ‘show’ parameter
- Arguments:
show : bool - Indicates whether to show (true) or hide (false) the mouse cursor
- set_mouse_cursor_locked(lock: bool = true)
Locks the mouse cursor to the window and automatically hides it. Escape button can be used to unlock the cursor.
- Arguments:
lock : bool - if true, the mouse cursor will be locked to the window. If false, the mouse cursor will be unlocked.
Note
The mouse cursor will be hidden while locked, and will reappear when unlocked.
The mouse lock will be applied instantly when the system processes UI events such as UIMouseEventType.MouseDown, UIMouseEventType.MouseUp, or UIMouseEventType.MouseClick. The user won’t need to click a second time to lock the cursor.
Note
The mouse cursor can only be locked if the window has focus, so the user may need to click on the window to switch focus to it.
is_mouse_cursor_locked function can be used to check if the mouse cursor is actually locked.
- get_mouse_cursor_locked(): bool
- Returns:
bool - true if
set_mouse_cursor_lockedwas called withtrue, false otherwise
- is_mouse_cursor_locked(): bool
- Returns:
bool - true if the mouse cursor is locked, false otherwise
Garbage collector
- get_gc_enabled(): bool
- Returns:
bool - whether the automatic garbage collection is currently enabled
- set_gc_enabled(enabled: bool)
enables or disables the automatic garbage collection
- Arguments:
enabled : bool - set true to enable automatic garbage collection, false to disable
Warning
Don’t disable garbage collection unless you know what you’re doing. Manual garbage collection should only be used when there are issues with the automatic garbage collection.
- gc_collect_strings()
Performs garbage collection specifically in the strings heap
- gc_collect_heap()
Performs garbage collection specifically in the global heap (excluding strings)
- gc_collect_all()
Performs garbage collection both in the global heap and in the strings heap
Cheats
exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any) : bool
exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any) : bool
exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any) : bool
exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any) : bool
- exec_cheat(cheat: string): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
- exec_cheat(cheat: string; arg1: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
- exec_cheat(cheat: string; arg1: any; arg2: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
- exec_cheat(cheat: string; arg1: any; arg2: any; arg3: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
arg3 : any
- exec_cheat(cheat: string; arg1: any; arg2: any; arg3: any; arg4: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
arg3 : any
arg4 : any
- exec_cheat(cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
arg3 : any
arg4 : any
arg5 : any
- exec_cheat(cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
arg3 : any
arg4 : any
arg5 : any
arg6 : any
- exec_cheat(cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any; arg7: any): bool
Invoke a registered cheat by given name.
- Arguments:
cheat : string
arg1 : any
arg2 : any
arg3 : any
arg4 : any
arg5 : any
arg6 : any
arg7 : any
- exec_cheat(arg0: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any; arg7: any; arg8: any): bool
Invoke a registered cheat by given name.
- Arguments:
arg0 : string
arg1 : any
arg2 : any
arg3 : any
arg4 : any
arg5 : any
arg6 : any
arg7 : any
arg8 : any
Command buffer
- has_read_bytes(cb: CommandBuffer implicit): bool
- Arguments:
cb : CommandBuffer implicit
- Returns:
bool - true if there are any bytes to read in the CommandBuffer, and false otherwise
- total_written_bytes(cb: CommandBuffer implicit): uint
- Arguments:
cb : CommandBuffer implicit
- Returns:
uint - the total number of bytes written to the command buffer
- get_name(cmd: GenericCommand implicit): string
Get the name of the given command
- Arguments:
cmd : GenericCommand implicit - The command to get the name of
- Returns:
string - The name of the command