-
-
Notifications
You must be signed in to change notification settings - Fork 9
OSL ‐ Subroutines
Place this code in the setup part of your code before the mainloop label.
These can be run from inside of imported files
def "name" "input1" "input2"
// code goes in here
variable = "data"
// this variable is global scope
this.variable = "data"
// only accessible inside this def
endef
name "hi" 123
// running the def
In osl, this
is a local object that you can manipulate and add to that has data only accessible inside of the current thread
def "hello"
this.test_val = "hello world"
log this
error this.test_val
// console.error(test_val)
endef
hello
log this.test_val
// logs "" because test_val is undefined
Place this code in the setup part of your code before the mainloop label.
These cannot be run from inside of imported files
method "input.method(input2)"
// run your method code
return "data"
endmethod
log "hi".method()
// this passes "hi" and null to the method and then logs "data"
method "text_data.makeLetters()"
data = []
// new array
i = 0
loop text_data.len (
i ++
// increment counter
letter = text_data.[i]
// get letter of string
data = data.append(letter)
// push letter of string onto data array
)
return data
// return the array
endmethod
log "hello".makeLetters()
// logs ["h","e","l","l","o"]
Place this code in the setup part of your code before the mainloop label.
Events are checked after your script finishes running.
event "value1" "condition" "value2"
endev
-
"pressed"
: Runs the event if a key is pressed. -
"=="
: Runs the event ifvalue1
is the same asvalue2
. -
"!="
: Runs the event ifvalue1
is different fromvalue2
.
def "test_command" "input1,input2"
// Your custom command logic here
log input1
log input2
endef
test_command "hello" 10
event "space" "pressed"
if touched_ground (
y_velocity = 30
)
endev
These commands and structures allow you to define custom commands and event-based logic in your OSL script, providing flexibility and organization in your code.
originOS is a web desktop gui with a self contained file system, programming languages, internet system and a whole lot of stuff an os should be able to do Use originOS here