OSL ‐ Saving Data Locally - Mistium/Origin-OS GitHub Wiki

Basic Save Commands

Getting your save data contents

save "contents"
log save_data
// logs an array of the files in your save data

Setting the directory for your save data

save "myapp@myusername" "set_directory"
if save_data == "success" (
  // the set was successful
)
if save_data == "Failed (Permissions)" (
  // was unable to choose this directory due to a lack of permissions
  // this will add a popup for the user to allow the app to access that save data
)
if save_data == "Failed (Invalid)" (
  // was unable to choose this directory because it has a "/" in it
)
// a basic app data directory to use for your applications

mainloop:
// enter the mainloop

if save_directory == "" (
  loc 2 2 10 -20
  text "Waiting for save directory to be allowed" 10 : c#fff
  // display a waiting message at the top left

  import "win-buttons"
  exit
  // end the program execution for this frame
)

import "win-buttons"

This will only happen if an app asks for access to a save directory thats already been taken Screenshot 2024-08-24 at 11 51 32

Adding data to your application's local storage

save "data.txt" "set" "Hello, World!"

Appending to your save data

same line append

save "data.txt" "append" " Goodbye now!"

this command when run on our file data.txt would update it's value to:

Hello, World! Goodbye now!

new line append

(v4.7.7 and later)

save "data.txt" "newline" "Goodbye now!"

this command when run on our file data.txt would update it's value to:

Hello, World!
Goodbye now!

Getting data from your save

(use save-data in versions 4.7.6 and earlier)

save "data.txt" "get"

my_text = save_data

Checking if a save file exists

(v4.7.7 and later)

save "data.txt" "exists"

if save_data == true (
  // save_data is `true` if the file exists
) else (
  // save_data is `false` if the file doesn't exist
)