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
Bindspathto a temporary file path according totempfileand 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_LOGFILEis 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,AppDataon Windows, andXDG_CONFIG_HOMEeverywhere 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 passTto fetch the answer without the context of amaininstance.prevent-powersave
Try to prevent the system from entering powersave mode or activating the screensaver. You must regularly callping-powersaveafterwards, andrestore-powersaveonce you're done.