Discord

Preparing your files

Please wait until the download is ready.

Luka's Scripting Utilities

Luka's Scripting Utilities

by Luka S.J.

A pack full of various scripting utilities to ease your development!

v4.1.135,194
Download144 KB

Filesystem & Environment

Helpers for working with files, directories and well-known system paths.

File

  • File.safe_data?(file) safely checks whether a .rxdata file exists and is loadable (it attempts the load and returns a boolean rather than raising)

Dir

  • Dir.create(path) recursively creates every directory needed for a path
  • Dir.all_dirs(path) walks a directory tree and returns every directory found within it
  • Dir.delete_all(path) deletes all files in a directory and its subdirectories (works on non-empty directories)

Env

Env resolves well-known Windows directories by GUID and escapes reserved
filesystem characters.

  • Env.path(type) resolves a known directory path from its key (e.g. 'DESKTOP', 'DOCUMENTS', 'DOWNLOADS')
  • Env.directory the current working directory of the game
  • Env.guid_to_hex(string) converts a GUID string to the hex array format the OS expects
  • Env.char_esc(string) escapes reserved filesystem characters in place
  • Env.char_dsc(string) restores previously escaped characters in place

Known path keys (COMMON_PATHS)

CAMERA_ROLL, START_MENU, DESKTOP, DOCUMENTS, DOWNLOADS, HOME,
MUSIC, PICTURES, SAVED_GAMES, SCREENSHOTS, VIDEOS, LOCAL,
LOCALLOW, ROAMING, PROGRAM_DATA, PROGRAM_FILES_X64,
PROGRAM_FILES_X86, COMMON_FILES, PUBLIC.

desktop = Env.path('DESKTOP')
Dir.create(desktop + '/MyGame/exports/')

The reserved characters handled by char_esc / char_dsc are
\ / : * ? ' < > |.