Skip to content

System

The System class provides access to the running Nutshell virtual machine information, environment properties, and lifecycle management.


Synopsis

Static Methods

Static Members


Static Methods

System.exit([code])

Requests application shutdown with an optional exit code.

Parameters:

Parameter Type Required Description
code int No The code to use as application exit code. Default: 0.

System.fps()

Get the rendered frames per seconds for the current virtual machine.

  • Returns: float: Current rendered frames per seconds for the current virtual machine.

System.resolve_path(path)

Converts a raw path or resource URI into a canonical absolute path.

Parameters:

Parameter Type Required Description
path string Yes The raw path (e.g., "./config.nut") or resource path (e.g., "res://config.nut") to resolve.
  • Returns: string: The absolute, canonical path.

System.script_path()

Get the current script path.

  • Returns: string: The script path of the running script.

System.spawn_vm(scriptPath[, id])

Spawns a new virtual machine and let it run the given script.

Parameters:

Parameter Type Required Description
scriptPath string Yes The script to use for the newly spawned virtual machine.
id string No An optional specific identifier to assign to the newly spawned virtual machine.
  • Returns: string: The newly spawned VM identifier.

System.stop_vm(id)

Stops a virtual machine by its identifier.

Parameters:

Parameter Type Required Description
id string Yes The identifier of the virtual machine to stop.

System.ups()

Get the updates per seconds for the current virtual machine.

  • Returns: float: Current updates per seconds for the current virtual machine.

System.vm_count()

Get the number of currently active virtual machines.

  • Returns: int: The current count of active virtual machines.

Static Members

System.arch

  • Type: string

The current running operating system architecture.

System.id

  • Type: string

The current running virtual machine identifier.

System.project_root

  • Type: string

The current project root directory.

System.os

  • Type: string

The current running operating system flavor.

System.version

  • Type: string

The current semantic version of Nutshell.

System.version_commit

  • Type: string

The commit part of Nutshell's semantic version.

System.version_is_wip

  • Type: bool

true if this is a work in progress Nutshell build, false otherwise.

System.version_major

  • Type: int

The major part of Nutshell's semantic version.

System.version_minor

  • Type: int

The minor part of Nutshell's semantic version.

System.version_patch

  • Type: int

The patch part of Nutshell's semantic version.

System.version_prerelease

  • Type: string

The prerelease part of Nutshell's semantic version.


Examples

Example code available here.