-
Notifications
You must be signed in to change notification settings - Fork 0
Events
Mistium edited this page Jul 31, 2024
·
1 revision
RTR works entirely off of events, allowing the language to be very efficient since it doesn't need to run excess code when the user is doing nothing
event [event] {
// code
}
Example code:
event update {
frames += 1
log("this runs every frame")
}
event onload {
frames = 0
}
event mouse onmove {
event = window.mouse
log(event.data.x, event.data.y)
}
You can manually run an event using the syntax below:
call [event name]
// this directly runs the event, by name, and waits until it stops executing
call async [event name]
// this runs the event in parallel without pausing the parent event
Here is a list of events:
onload
// the first frame that the script is executed
update
// every frame this will be called
render
// whenever a re-render is needed
resize
// when the screen is resized
// mouse buttons
mouse left.down
// run on left mouse click
mouse left.up
// run on left mouse release
mouse right.down
// run on right mouse click
mouse right.up
// run on right mouse release
mouse middle.down
// run on middle mouse click
mouse middle.up
// run on middle mouse release
// mouse position
mouse onmove
// Keyboard presses
key [keyname].down
// run when the key is pressed
key [keyname].up
// run when the key is released