Operating System Interaction
Trial offers a number of functions to interact with the operating system facilities in a portable fashion. Since this is more of a toolkit kind of thing, here's a list of relevant functions:
data-root
Returns the runtime directory of the game, which is either the executable directory in deployed mode, or the system source directory in dev mode.current-time
Returns a monotonic clock in seconds as a double float. The precision is implementation defined, but may very well be higher than internal-real-time.open-in-browser
Will open the given URL in a browser. This will also take care of using platform-specific browsers such as when Steam is used.open-in-file-manager
Will open the given path in a file manager.envvar-directory
Retrieve the directory described by an environment variable. May also return NIL if the variable is unset or empty.tempdir
Return a path to the local system's temporary directory. Files in here may be deleted when the application exits, or when the system restarts.tempfile
Return a path to a temporary file. Note: this function does not guarantee that the requested file does not already exist. Please use a loop overwith-open-file
.with-tempfile
Bindspath
to a temporary file path according totempfile
and ensures the file is deleted when body exits.logfile
Returns the path to the central Trial log file, typically stored next to the executable unless the environment variableTRIAL_LOGFILE
is set.config-directory
Returns the path to the directory to use to store configuration and save files. This can be configured through the environment variableTRIAL_CONFIG_HOME
,AppData
on Windows, andXDG_CONFIG_HOME
everywhere else. The path is dependent on the+app-vendor+
and+app-system+
.username
Returns a descriptive name of the current user. This may be a human-readable display name of some sort, or their user account name. You may passT
to fetch the answer without the context of amain
instance.io-bytes
A monotonically increasing count of bytes read or written by the process.cpu-time
A monotonically increasing floating point number of seconds of CPU time spent by the process.gpu-room
Returns two values: the number of kilobytes of free VRAM, and the total number of kilobytes of VRAM.cpu-room
Returns two values: the number of kilobytes of free RAM, and the total number of kilobytes of RAM.prevent-powersave
Try to prevent the system from entering powersave mode or activating the screensaver. You must regularly callping-powersave
afterwards, andrestore-powersave
once you're done.