.. _stdlib_public_system: ====== 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 ++++++++++++++++++ .. _handle-public_command_buffer-GenericCommand: .. das:attribute:: 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 .. _handle-public_command_buffer-CommandBuffer: .. das:attribute:: 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 ++++++++++++++++++++ .. _handle-public_console-cheat: .. das:attribute:: 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 +++++++++ * :ref:`get_target_fps () : float ` * :ref:`set_target_fps (value: float) : float ` * :ref:`get_resolution () : int2 ` * :ref:`open_url (url: string implicit) : bool ` * :ref:`warning (text: string implicit) ` * :ref:`print (text: string implicit) ` * :ref:`error (text: string implicit) ` .. _function-public_system_get_target_fps: .. das:function:: get_target_fps() : float :Returns: * float - the target frame rate of the user script execution .. _function-public_system_set_target_fps_float: .. das:function:: 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 .. _function-public_system_get_resolution: .. das:function:: get_resolution() : int2 :Returns: * int2 - the resolution of the screen as (x, y) coordinates .. _function-public_system_open_url_string_implicit: .. das:function:: 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 .. _function-public_system_warning_string_implicit: .. das:function:: warning(text: string implicit) prints the provided line to console, marking it as a warning :Arguments: * **text** : string implicit .. _function-builtin_print_string_implicit: .. das:function:: print(text: string implicit) prints the provided line to console :Arguments: * **text** : string implicit .. _function-builtin_error_string_implicit: .. das:function:: error(text: string implicit) prints the provided line to console, marking it as an error :Arguments: * **text** : string implicit ++++++++++++++++++++++ Mouse cursor functions ++++++++++++++++++++++ * :ref:`show_mouse_cursor (show: bool = true) ` * :ref:`set_mouse_cursor_locked (lock: bool = true) ` * :ref:`get_mouse_cursor_locked () : bool ` * :ref:`is_mouse_cursor_locked () : bool ` .. _function-public_system_show_mouse_cursor_bool: .. das:function:: 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 .. _function-public_system_set_mouse_cursor_locked_bool: .. das:function:: 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. :ref:`is_mouse_cursor_locked ` function can be used to check if the mouse cursor is actually locked. .. _function-public_system_get_mouse_cursor_locked: .. das:function:: get_mouse_cursor_locked() : bool :Returns: * bool - true if ``set_mouse_cursor_locked`` was called with ``true``, false otherwise .. _function-public_system_is_mouse_cursor_locked: .. das:function:: is_mouse_cursor_locked() : bool :Returns: * bool - true if the mouse cursor is locked, false otherwise +++++++++++++++++ Garbage collector +++++++++++++++++ * :ref:`get_gc_enabled () : bool ` * :ref:`set_gc_enabled (enabled: bool) ` * :ref:`gc_collect_strings () ` * :ref:`gc_collect_heap () ` * :ref:`gc_collect_all () ` .. _function-public_system_get_gc_enabled: .. das:function:: get_gc_enabled() : bool :Returns: * bool - whether the automatic garbage collection is currently enabled .. _function-public_system_set_gc_enabled_bool: .. das:function:: 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. .. _function-public_system_gc_collect_strings: .. das:function:: gc_collect_strings() Performs garbage collection specifically in the strings heap .. _function-public_system_gc_collect_heap: .. das:function:: gc_collect_heap() Performs garbage collection specifically in the global heap (excluding strings) .. _function-public_system_gc_collect_all: .. das:function:: gc_collect_all() Performs garbage collection both in the global heap and in the strings heap ++++++ Cheats ++++++ * :ref:`exec_cheat (cheat: string) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any) : bool ` * :ref:`exec_cheat (cheat: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any; arg7: any) : bool ` * :ref:`exec_cheat (arg0: string; arg1: any; arg2: any; arg3: any; arg4: any; arg5: any; arg6: any; arg7: any; arg8: any) : bool ` .. _function-public_console_exec_cheat_string: .. das:function:: exec_cheat(cheat: string) : bool Invoke a registered cheat by given name. :Arguments: * **cheat** : string .. _function-public_console_exec_cheat_string_any: .. das:function:: exec_cheat(cheat: string; arg1: any) : bool Invoke a registered cheat by given name. :Arguments: * **cheat** : string * **arg1** : any .. _function-public_console_exec_cheat_string_any_any: .. das:function:: exec_cheat(cheat: string; arg1: any; arg2: any) : bool Invoke a registered cheat by given name. :Arguments: * **cheat** : string * **arg1** : any * **arg2** : any .. _function-public_console_exec_cheat_string_any_any_any: .. das:function:: 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 .. _function-public_console_exec_cheat_string_any_any_any_any: .. das:function:: 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 .. _function-public_console_exec_cheat_string_any_any_any_any_any: .. das:function:: 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 .. _function-public_console_exec_cheat_string_any_any_any_any_any_any: .. das:function:: 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 .. _function-public_console_exec_cheat_string_any_any_any_any_any_any_any: .. das:function:: 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 .. _function-public_console_exec_cheat_string_any_any_any_any_any_any_any_any: .. das:function:: 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 ++++++++++++++ * :ref:`has_read_bytes (cb: CommandBuffer implicit) : bool ` * :ref:`total_written_bytes (cb: CommandBuffer implicit) : uint ` * :ref:`get_name (cmd: GenericCommand implicit) : string ` .. _function-public_command_buffer_has_read_bytes_CommandBuffer_implicit: .. das:function:: has_read_bytes(cb: CommandBuffer implicit) : bool :Arguments: * **cb** : :ref:`CommandBuffer ` implicit :Returns: * bool - true if there are any bytes to read in the CommandBuffer, and false otherwise .. _function-public_command_buffer_total_written_bytes_CommandBuffer_implicit: .. das:function:: total_written_bytes(cb: CommandBuffer implicit) : uint :Arguments: * **cb** : :ref:`CommandBuffer ` implicit :Returns: * uint - the total number of bytes written to the command buffer .. _function-commands_core_get_name_GenericCommand_implicit: .. das:function:: get_name(cmd: GenericCommand implicit) : string Get the name of the given command :Arguments: * **cmd** : :ref:`GenericCommand ` implicit - The command to get the name of :Returns: * string - The name of the command