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
        • Video
        • 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(val,num)
      • .padEnd(val,num
      • .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
  • Equal to (==) (===)
  • Case Insensitive
  • Case Sensitive
  • Greater than
  • Less than
  • Checking Contains
  • Ternary Operator (?)
  • Inverting A Comparison

Was this helpful?

Edit on GitHub
  1. Operators

Comparative Operators

A comparative operator is an operator that takes in operands and returns a boolean.

Equal to (==) (===)

When you want to check if a value is equal to another value in osl, there's multiple levels of how to do it.

Case Insensitive

When you want to do an equals check for two values that is case and type insensitive, you can use ==

log "hello" == "Hello"
// this will return true

Case Sensitive

When you want to do an equals check for two values that is case and type sensitive, you can use ===

log "hello" === "Hello"
// this will return false

log "world" === "world"
// this will return true

Type Sensitivity is also a benefit of using ===

log "10" == 10
// this will return true

log "10" === 10
// this will return false

Greater than

You can check if a value is greater than another using the > operator. Greater than is always case insensitive when using strings

log 10 > 5
// this will return true
// 10 is greater than 5

log "a" > "b"
// this will return false because a is before b in the alphabet
// you can also use !> for strings too

log 5 >= 5
// returns true
// this will check if both values are greater than or equal to each other

Less than

You can also do the inverse of greater than and check if a value is less than another using the < operator

log 10 < 5
// this will return false
// 10 is less than 5

log "a" < "b"
// this will return true because a is before b in the alphabet

log 5 <= 5
// returns true
// this will check if both values are less than or equal to each other

Checking Contains

You can check if a value contains another value using

log "1" in "1234"
// returns true

Ternary Operator (?)

The ? operator provides a shorthand way to write simple if-else statements. It takes three operands: a condition followed by two values, where the first value is returned if the condition is true, and the second value if it's false.

// Basic syntax:
condition ? value1 value2

// Examples
age = 20
status = age >= 18 ? "adult" "minor"
// If age is >= 18, status will be "adult", otherwise "minor"

score = 85
result = score > 60 ? "pass" "fail"
// If score is > 60, result will be "pass", otherwise "fail"

// Can be used in expressions
text "Points: " + (points > 100 ? "max" points)
// Shows "max" if points > 100, otherwise shows the points value
// Note: The + operator here adds a space between "Points: " and the result

Inverting A Comparison

You can simply place a ! infront of any comparison below to make it do the opposite of the norm.

log 10 != 5
// returns true
// functions as the inverse of ==

log 10 !== 5
// returns true
// functions as the inverse of ===

log 10 !> 5
// returns false
// functions as the inverse of >

log 10 !< 5
// returns true
// functions as the inverse of <

log "1" !in "1234"
// returns false
// functions as the inverse of in
PreviousArray OperationsNextLogical Operators

Last updated 1 month ago

Was this helpful?