Skip to content
Mistium edited this page Aug 17, 2024 · 20 revisions

About

Functions in osl are simple expressions that only take parameters and no inputs, unlike methods which take one input and additional parameters.

Functions are very useful for when all the input data is of the same importance.

List

Here are a list of all current built in osl functions:

log random()
// a random number between 0 and 1
// example: 0.11885152874733729

log ouidNew()
// returns an almost true random id
// example: d2f18789d657a5374502a739100c2e51999212b8

log random(1,10)
// returns a random number between a range
// example: 3

log dist(x,y,x2,y2)
// returns the distance between two xy positions

log min(10,20)
// returns the lower input value
// example: 10
// this also supports strings

log max(10,20)
// returns the higher input value
// example: 20
// this also supports strings

log lcm(5,3)
// finds the lowest common multiple of two numbers
// example: 15

log gcd(5,3)
// finds the greatest common divisor of two numbers
// example: 5

log regex(pattern,flags)
// builds a regex

log average(10,15,3)
log average(10,15,3,5,1,2)
// finds the average of all numbers inputted

log join(delimeter,string,string)
// joins all inputs with a delimiter
// example: join(":",minute,second) > "45:08"

log sum(10,15,3)
log sum(10,15,3,5,1,2)
// finds the total of all the numbers inputted

Define a custom function using this syntax

def "func(this.input)"
  return "function got: " ++ this.input
endef

say func("hello world")

originOS Wiki

Wiki Views:
:views

OSL | RSH | ICN

Clone this wiki locally