System
The System module contains functions and constants that don't fit in many other places.
data_directoryreturns the assigned directory for saving data. This will be eitherAppData,Application Supportor.local/sharedepending on platform.window_titleandwindow_title=(str)get and set the window's title tostrrespectively.raw_key_statesreturns 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 anMKXPErrorif it fails for whatever reason.user_languagereturns the user's locale (e.g. "en_US")game_titlereturns the game's title.power_statereturns 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_settingsraises the keybinding menunprocreturns the number of processor threadsmemoryreturns the total amount of memory available in the machineuptimereturns the amount of time passed since the application was started (in microseconds). Also aliased asdelta.
System::VERSIONis 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::CONFIGis 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
platformreturns 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_cachecauses MKXP to regenerate its path cache, reflecting changes made in the mounted filesystem since it was last called.mount(path[, mountpoint[, reload]])will mountpathtomountpoint. Multiple locations can be mounted to the same mount point, and any archive formats you can use with theRTPsoption in mkxp's json configuration can also be mounted as directories (e.g. zip, rgssad, iso). Ifmountpointis not provided, it will default to the game's root, not the same path specified inpath. Automatically reloads the path cache ifreloadis not specifically set false.unmount(path[, reload])removespathfrom MKXP's search path. This is the same path given to the first argument ofmount, not the mount point. Automatically reloads the path cache ifreloadis not specifically set false.
Last updated