System
The System
module contains functions and constants that don't fit in many other places.
data_directory
returns the assigned directory for saving data. This will be eitherAppData
,Application Support
or.local/share
depending on platform.window_title
andwindow_title=(str)
get and set the window's title tostr
respectively.raw_key_states
returns a byte string containing all of MKXP's key states.launch(cmd[, args])
opens the path or link address with the user's default program. For instance,System.launch("https://www.google.com")
would open Google in the default web browser,System.launch(System.data_directory)
would open the game's save folder in the file explorer, andSystem.launch("log.txt")
would open a plaintext file using whatever the user has assigned to open plaintext files with. Raises anMKXPError
if it fails for whatever reason.user_language
returns the user's locale (e.g. "en_US")game_title
returns the game's title.power_state
returns a hash containing three entries, all of them able to benil
::discharging
: whether the machine is connected to sufficient power:percent
: the remaining percentage of the battery:seconds
: the estimated remaining time for the battery in seconds
show_settings
raises the keybinding menunproc
returns the number of processor threadsmemory
returns the total amount of memory available in the machineuptime
returns the amount of time passed since the application was started (in microseconds). Also aliased asdelta
.
System::VERSION
is a constant that returns mkxp-z build version. It's defined in either the rootmeson.build
, or from within the build settings of the Xcode targets.System::CONFIG
is a hash containing the parsed JSON data of the configuration file. If the JSON couldn't be read or never existed, this hash is empty.
Platform Detection
platform
returns a string describing the platform MKXP is currently running on.is_windows?
/is_mac?
/is_linux?
return true if MKXP was built for the respective operating system.is_rosetta?
returns true if MKXP is being run over Rosetta 2 -- in other words, if it is being run as Intel code on an ARM Mac.is_wine?
returns true if MKXP is being run on Linux or macOS through Wine.is_really_windows?
/is_really_mac?
/is_really_linux?
are similar to the functions above, but unlike those, are not tricked by Wine.
The Path Cache
MKXP's classes do not directly use the native filesystem. Instead, by default, the game's directory is mounted to appear as the current directory, along with the game's archive if it has one, and any locations specified as RTPs in the configuration file.
If you wish to create Bitmaps, play audio, use load_data
, etc. on files or archives not initially indicated to MKXP, or on files or archives that were not pre-existing at the time MKXP was started, these are for you.
desensitize(path)
uses MKXP's internal path cache to find the correct case for a filename. Useful for scripting filesystem operations on platforms with case-sensitive filesystems, like macOS and Linux.reload_cache
causes MKXP to regenerate its path cache, reflecting changes made in the mounted filesystem since it was last called.mount(path[, mountpoint[, reload]])
will mountpath
tomountpoint
. Multiple locations can be mounted to the same mount point, and any archive formats you can use with theRTPs
option in mkxp's json configuration can also be mounted as directories (e.g. zip, rgssad, iso). Ifmountpoint
is not provided, it will default to the game's root, not the same path specified inpath
. Automatically reloads the path cache ifreload
is not specifically set false.unmount(path[, reload])
removespath
from MKXP's search path. This is the same path given to the first argument ofmount
, not the mount point. Automatically reloads the path cache ifreload
is not specifically set false.
Last updated