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
  • Commands
  • Assignments
  • Operators
  • Methods
  • Functions
  • Statements
  • Getting Started

Was this helpful?

Edit on GitHub
  1. Basics

Syntax

NextTypes

Last updated 12 days ago

Was this helpful?

OSL programming is made up of 6 different types of syntax.

Commands

Commands are the backbone of most OSL scripts— generally, any operation involving modifying the program's state is done through them. They accept multiple inputs after the initial command, seperated by spaces. These inputs can be constants, such as raw strings or numbers, operators (which are defined later), or variables. Commands have no return value.

command input1 input2 input3...
// Moves the "draw cursor" to the origin of the screen.
goto 0 0

// Outputs the draw cursor's new location to the JavaScript console.
log x_position y_position

Assignments

As the name suggests, assignments apply a value to the specified variable. The second token in an assignment will always be an , usually taking the form of an equals sign (=). Assignments only take one input (aside from the initially specified variable), and do not have a return value.

variable assignment input
// Sets variable "var" to 10.
var = 10

// Inputs can also be previously defined variables.
varTwo = var
log varTwo

Operators

// Variable "var" will be set to the solution of the operator equation.
var = 10 + 5

// Multiple operators can be strung together at once, but will be calculated left to right.
varTwo = var + 5 / 2

// Operators can assess logic gates.
log var == 15 and varTwo == 10

Methods

Methods return a modified value based on a singular input. Methods can follow any constant or variable, and that value will act as it's input. Values inside the parentheses will act as parameters, although not every method will require those. In cases with multiple parameters, each value is seperated by a comma.

// Logs the sine of 10 to the console.
log 10.sin()

// An example of a method with parameters; the parameter will be joined with the input.
var = "hello "
log var.concat("world")

Methods don't necessarily need to be part of another statement. In cases where a method is isolated, the input will automatically be updated to the method's return value.

// These two lines are functionally equivalent.
var.method()
var = var.method()

Functions

// Logs a random number 1 through 10.
log random(1, 10)

// An example of an isolated function with the parameters 10 and 5.
func(10, 5)

Statements

// The "if" statement only runs its commands if the input is true.
score = random(1, 15)
if score >= 10 (
  log "Required score met."
)

// The "loop" statement runs its commands multiple times.
loop 3 (
  log "Crazy? I was crazy once."
)

// Logs all values 1 through 10.
for i 10 (
  log i
)

Getting Started

Below are some helpful pages to learn more about:

Operators return a value based on a calculation. Operators can either be (addition, subtraction, division, etc.), (==, <, >, etc.) or (and, or, nor, etc.). Unless parentheses are used, operators will always be processed from left to right, ignoring mathematical order of operations.

Functions are similar to methods, with the main difference being that functions do not take an input. Functions typically return a value, however this isn't strictly required— functions lacking an output won't throw an error, but instead output . Similarly to methods, functions can be run on their own, however no values will be modified.

Statements are containers for other commands, and modify their behavior through or . Statements are always followed by a set of parentheses which surround a script. They generally take one or more inputs, supplied between the statement itself and the opening parenthesis.

assignment operator
equations
comparisons
logic gates
looping the statement
ignoring it if the specified conditions aren't met
Basic Syntax
Program Flow
String Methods
Math Functions
Utility Methods
null