Origin Scripting Language
  • Basics
    • Syntax
    • Types
    • The Execution Loop
    • Defining Variables
      • Clone Objects (=)
      • References To Objects/Variables (@=)
    • Assignment Operators
    • Local Scoping
    • Typed Variables
  • Operators
    • Mathematical Usage
      • Addition Operator (+)
      • Subtraction Operator (-)
      • Divide Operator (/)
      • Multiply Operator (*)
      • To The Power Of (^)
      • Modulo Operator (%)
    • Text Usage
    • String Concatenation Operator (+)
    • Array Operations
    • Comparative Operators
    • Logical Operators
    • Bitwise operators
    • Pipe Operator (|>)
    • Nullish Coalescing Operator (??)
  • Program Flow
    • If Statements
      • if truthy (
      • ) else if truthy (
      • ) else (
      • )
    • Switch Case
    • Iteration
    • While And Until
    • Dynamic OSL Execution
  • Arrays And Objects
    • Making Arrays Or Objects
    • Modifying An Array
    • Clone Objects And References
    • Object Operations
    • Object Property Shorthand
  • Environment
    • The Window System
    • Mouse Cursor
    • Camera
    • Sound System
    • Input Simulation
    • Running Other Languages
    • Notifications
    • Send Data Between Windows
    • Interfacing With Rightclick
    • Permissions
    • Files
      • What is a file? (in ofsf)
      • Creating Directories
      • open("file_path")
      • fileGet(int)
      • listFiles()
  • Storage
    • Save DB
    • Local DB
  • Custom Syntax
    • Commands
    • Methods
    • Functions
    • Inline
    • Lambda
    • Spread Operator
    • Typed Parameters
    • Classes
    • Promises
  • External
    • Make An Iframe App
  • Commands
    • Debugging
      • log "hello world"
      • warn "you should change this"
      • error "something went wrong"
      • void expression
    • Rendering
      • Basics
        • Color Commands
        • Color Picker
        • Modifiers
      • Draw Cursor
        • goto x y
        • set_x x
        • set_y y
        • change_x x
        • change_y y
        • change x y
        • loc a b c d
      • Elements
        • Canvas
        • Rectangle
        • Triangle
        • Icon
        • Text
        • Image
        • Input
        • Pen
        • Hitbox
        • Bar
        • Slider
      • ICN (Icon System)
        • Drawing Commands
        • Dynamic Icons
      • Clipping And Scrolling (frames)
      • 3D Rendering
  • Functions
    • Math
      • Math()
      • random(low,high)
      • min(num1,num2)
      • max(num1,num2)
      • lcm(num1,num2)
      • gcd(num1,num2)
      • sum(num1,..)
      • average(num1,..)
      • dist(x1,y1,x2,y2)
      • degtorad(angle)
      • radtodeg(angle)
      • noise(x, y, z)
      • octaveNoise(x, y, z, octaves, persistence)
    • Types
      • typeof(value)
      • symbol(name)
    • Encoding
      • encodeURIComponent(string)
      • decodeURIComponent(string)
      • btoa/atob(string)
    • function()
    • formatFileSize(bytes)
    • getGamepads()
    • import(path)
    • ouidNew()
    • parseFilePath(path)
  • Global Variables
    • Overview
    • System Information
    • User Information
    • Date and Time
    • Input State
    • Display and UI
    • Network
    • File System
  • Methods
    • Strings
      • .padStart(num,val)
      • .padEnd(num,val)
      • .startsWith(val)
      • .endsWith(val)
      • .wrapText(characters)
      • .trimText(characters)
      • .split(characters)
      • .count(val)
      • .replace(old,new)
      • .replaceFirst(old,new)
      • .oslTokenise()
      • .strip()
      • .toOrdArray()
      • .match(pattern)
      • Encoding
        • .encodeBin()
        • .decodeBin()
        • .encodeHex()
        • .decodeHex()
        • .encodeUTF16()
        • .decodeUTF16()
        • .encrypt(password)
        • .decrypt(password)
        • .ord()
        • .chr()
      • Hashing
        • .hashMD5()
        • .hashSHA1()
        • .hashSHA256()
        • .hashSHA512()
      • Case
        • .toLower()
        • .toUpper()
        • .toMixed()
        • .toTitle()
    • Keyboard
      • .isKeyDown()
      • .onKeyDown()
    • Utilities
      • .len
      • .not
      • .ask()
      • .reverse()
      • .first()
      • .last()
      • .append(val)
      • .prepend(val)
      • .insert(location,val)
      • .delete(location)
      • .concat(val)
      • .trim(idx1,idx2)
      • .left(num)
      • .right(num)
      • .contains(val)
      • .index(val)
    • Maths
      • .abs()
      • .invabs()
      • .log()
      • .ln()
      • .isPrime()
      • .sqrt()
      • .sign()
      • .chance()
      • .clamp(low,high)
      • .toBase(base)
      • Rounding
        • .round(places)
        • .ceiling()
        • .floor()
      • Trigonometry
        • .sin
        • .cos
        • .tan
        • .asin()
        • .acos()
        • .atan()
        • .radSin()
        • .radCos()
    • Iframes
      • .iframeNew()
      • .iframeGoto()
      • .iframeResize()
      • .iframeRedirect()
      • .iframeShow()
      • .iframeHide()
      • .iframeClose()
    • JSON
      • Arrays
        • .pop()
        • .shift()
        • .randomOf()
        • .sort(direction)
        • .sortBy(key,direction)
        • .swap(idx1,idx2)
        • .fill(value)
        • .join(characters)
        • .map(callback)
        • .filter(callback)
        • .some(callback)
        • .every(callback)
      • Objects
        • .getKeys(keys)
        • .getValues()
      • .JsonStringify()
      • .JsonParse()
      • .JsonFormat()
      • .JsonClean()
    • Types
      • .getType()
      • .isType(type)
      • .toNum()
      • .toBool()
      • .toStr()
    • Functions
      • .bind(context)
    • Networking
      • .httpGet()
      • .http(method,data,headers)
      • .getAsync()
      • .roturConnect()
      • .roturSend(msg,target)
      • Websockets
        • .newWebsocket()
        • .wsSend(msg)
        • .wsClose()
        • .wsOpen()
        • .wsHasnew()
        • .wsGetnext()
        • .wsGetcount()
    • Timestamp
      • .timestamp("convert-date")
      • .timestamp("component")
Powered by GitBook
On this page
  • Important
  • Showing the window
  • Modifying the window
  • Window Position
  • Window Size
  • Closing the window and execution control
  • Extra
  • DragBox
  • Create a new window
  • All endpoints on the window variable
  • Parents and Children
  • Parent Variables
  • File and code data
  • Window Location
  • Window Permissions
  • Accent Colour

Was this helpful?

Edit on GitHub
  1. Environment

The Window System

Important

OSL applications are all run as windows, even scripts, everything is a window.

Each file only has access to a single window and acts as only one window

If you want to do almost anything with the window in osl you will more than likely need to use either the window commands or the newer, window object

Showing the window

window.show()
// Shows the window (allowing the user to move/drag and resize the window by default)

window.hide()
// Hides the window, stopping all user interaction that is handled by origin

If a window is hidden and lacks a "mainloop:" label, it will be closed by origin when the program finishes execution.

Modifying the window

You can modify the parameters of your osl window in origin such as disabling resizing, moving, and changing the dimensions of your window.

Window Position

window.x = x
// set the window's x position

window.y = y
// set the window's y position

Window Size

window.setResizable(true)
// enables and disables the window from being resized by the user

window.resize(width, height)

window.width = width
window.height = height
// set the size of the window

Closing the window and execution control

window.close()
// this instantly closes the window and stops all code execution

exit "exit code"
// Ends the current cycle with a chosen exit code, if the program is hidden and 
// doesn't have a mainloop: it will be closed, otherwise it will jump to the end 
// of the script and start from the beginning next frame

window "responsive" true/false
// this disables origin's application sleep mode for this window, allowing you to continue running code even when the window is not in focus
// this may affect system performance depending on what code you are running

window.renderexec = true/false
// a boolean that enables or disables the window osl script running when hovered over with the mouse and not focused
// this is settable

window.framerate = (10 to 250)
// the fps that the window wants to be run at
// clamped between 10 and 250
// this is settable

window.no_desktop = true/false
// disables or enables the desktop system affecting your application.

Extra

If your window is hidden and you are rendering things, they may leave a trail behind, so when you move the thing you are rendering and need to clear the screen, use this window method.

window.callRender()
// this redraws the background behind your app

DragBox

window.setDragbox([2,2,0,0],[-2,-2,0,0])
// sets the dragbox to cover the whole window

// the top left position is the first array
// the bottom right position is the second array

Create a new window

window.create takes the (name / path / uuid) of an osl file and creates a new window using it. It also takes an object of parameters for the setup of the program.

window.create(window.file.uuid, { // all keys here are optional
  passed_data: "data", // the passed_data is what that window receives in the variable "passed_data"
  x: 0,                // the x position to spawn the new window at
  x_target: 0,         // where the window should interpolate to on the x axis
  y: 0,                // the y position to spawn the new window at
  y_target: 0,         // where the window should interpolate to on the y axis
  width: 1000,         // the width of the new window
  width_target: 1000,  // how wide the window should smoothly transition to
  height: 600,         // the height of the new window
  height_target: 600   // how tall the window should smoothly transition to
})
// add a new window from the same file (essentially clone this window)
// be careful because this can cause an infinite loop and crash osl

All endpoints on the window variable

Parents and Children

window.parent.id
// returns the window id of the window that created this window
// this key is not a direct reference to the parent id and changing it will not edit the parent id

window.parent.permissions
// the permissions of the window that created this window
// this key is not a direct reference to the parent permissions and changing it will not edit the parent permissions

window.parent.name
// the name of the window that created this window
// this key is not a direct reference to the parent name and changing it will not edit the parent name

window.children
// returns an array of the ids of windows that this window has created
// this key is not a direct reference to the window children and changing it will only affect your program

Parent Variables

In osl, if the parent window is running the same file as the child window, you can access the parent's variables by reference to edit and view them in real time.

Create a new window

if window.parent.file_uuid == window.file.uuid (
  // only run if the parent window is the same file
  if passed_data == "Child" (
    // only run if this window was created with the data "Child"
    vars @= window.parent.variables
    // get the parent window's variables by reference
    vars.hello += 1
    // increment the hello variable
    window "stop"
  )
)

hello = 10
// set hello to 10

window.create(window.file.uuid, {
  "passed_data": "Child"
})
// create a new window with the data "Child" from the same file

mainloop:
log hello
// keep logging the hello variable
// this changes from 10 to 11

File and code data

window.code
// returns the fully compiled code of the window (this is an array)
// this key is not a direct reference to the window code and changing it will not edit the code

window.permissions
// returns the permissions of the current window as an array
// example: ["file admin","camera"]
// this key is only a copy of the window permissions
// it will not edit the actual permissions if you change this

window.file.path
// this functions identically to window.permissions, it is not editable
// this will return the file path of the current osl file
// example: "origin/(c) users/username/downloads/new.osl"

window.file.uuid
// returns the uuid that leads to the file that controls this window

window.file.code
// this data is an array
// returns the current uncompiled code that is running

window.drop_location
// this data is settable
// allows you to set the folder that a file will be moved to when it is dropped onto this window

Window Location

window.top
// returns window.height / 2
// this is only a reference to the maths above, setting it will only persist for one cycle

window.bottom
// returns window.height / -2
// this is only a reference to the maths above, setting it will only persist for one cycle

window.left
// returns window.width / -2
// this is only a reference to the maths above, setting it will only persist for one cycle

window.right
// returns window.width / 2
// this is only a reference to the maths above, setting it will only persist for one cycle

window.width
// returns the width of the window
// This is settable

window.height
// returns the height of the window
// This is settable

Window Permissions

window.hasPermission(permission)
// Returns true if the window has the specified permission, false otherwise
// Example:
if window.hasPermission("camera") (
    // Use camera
) else (
    permission "request" "camera"
)

// Can check multiple permissions
if window.hasPermission("notifications") and window.hasPermission("sound") (
    // Play notification sound
)

Accent Colour

You can set the outline of your window using the window_accent variable

window_accent = #fff
// this sets the accent of the window
PreviousObject Property ShorthandNextMouse Cursor

Last updated 3 months ago

Was this helpful?

The window dragbox sets the hitbox where the user can drag on your window to move it around. This method takes two arrays of inputs in the same order and meaning as in an

Screenshot 2024-07-04 at 18 41 04
loc command.