How do I use code blocks in Facebook Horizon?

Item in LibraryItem in FolderParametersDescriptionTips
Events
When world is startedWhen world is startedEvent runs when world starts. This will happen when the first person enters the world's instance.
When event is receivedWhen event[myevent] with [obj] is receivedEvent runs when a custom event is received by this object. The custom event can be sent by the same script or a script on another object.
When trigger is entered by objectWhen event [triggerenter] with [obj] is receivedObject: The object that entered triggerEvent runs when an object enters the trigger gizmo.Note: The trigger must be configured to detect objects with a specific tag, and the object must have that tag.
When trigger is exited by objectWhen event [triggerexit] with [obj] is receivedObject: The object that exited triggerEvent runs when an object exits the trigger gizmo.Note: The trigger must be configured to detect objects with a specific tag, and the object must have that tag.
When trigger is entered by playerWhen event [triggerenter] with [player] is receivedPlayer: The player that entered the triggerEvent runs when a player enters the trigger gizmo.Note: The trigger must be configured to detect players.
When trigger is exited by playerWhen event [triggerexit] with [player] is receivedPlayer: The player that exited the triggerEvent runs when a player exits the trigger gizmo.Note: The trigger must be configured to detect players.
When colliding with objectWhen event [collisionenter] with [object] is receivedObject: The object that collided with the object that this script is attached to.Event runs when object collides with another object.Note: The object must be configured to detect collisions.
When colliding with playerWhen event [collisionenter] with [player] is receivedPlayer: The player that collided with the object this script it attached to.Event runs when object collides with the players head or torso.Note: The object must be configured to detect collisions.
When object is grabbed by playerWhen event [grabstart] with [player] is receivedPlayer: The player that grabbed the object that this script it attached toEvent runs when this object is grabbed by a player.
When object is released by playerWhen event [grabend] with [player] is receivedPlayer: The player that released the object that this script it attached toEvent runs when this object is released by a player.
When object is attached to playerWhen event [attachstart] with [player] is receivedPlayer: The player that attached the object that this script it attached toEvent runs when this object is attached to a player.Note: The object being manipulated must be marked as "Interactive" with "Grabbable" in order to be set as attachable.
When object is unattached from playerWhen event [attachend] with [player] is receivedPlayer: The player that unattached the object that this script it attached toEvent runs when this object is detached from a player.Note: The object being manipulated must be marked as "Interactive" with "Grabbable" in order to be set as attachable.
When index trigger is pressedWhen event [indextriggerdown] with [player] is received while self is grabbedPlayer: The player that pressed their trigger while holding the object that this script it attached toEvent runs when the index trigger on the oculus controller is pressed. This event will only work on an object that is being grabbed by a player.
When index trigger is releasedWhen event [indextriggerup] with [player] is received while self is grabbedPlayer: The player that released their trigger while holding the object that this script it attached toEvent runs when the index trigger on the oculus controller is released. This event will only work on an object that is being grabbed by a player.
When button1 is pressedWhen event [button1down] with [player] is received while self is grabbedPlayer: The player that pressed button 1 while holding the object that this script it attached toEvent runs when button 1 on the oculus controller is pressed. This event will only run on an object that is being grabbed by the hand that is holding the controller.Note: This event will only run on an object that is being grabbed by the hand that is holding the controller.
When button1 is releasedWhen event [button1up] with [player] is received while self is grabbedPlayer: The player that released button 1 while holding the object that this script it attached toEvent runs when button 1 on the oculus controller is released. This event will only run on an object that is being grabbed by the hand that is holding the controller.Note: This event will only run on an object that is being grabbed by the hand that is holding the controller.
When button2 is pressedWhen event [button2down] with [player] is received while self is grabbedPlayer: The player that released button 2 while holding the object that this script it attached toEvent runs when button 2 on the oculus controller is pressed. This event will only run on an object that is being grabbed by the hand that is holding the controller.Note: This event will only run on an object that is being grabbed by the hand that is holding the controller.
When button2 is releasedWhen event [button2up] with [player] is received while self is grabbedPlayer: The player that released button 2 while holding the object that this script it attached toEvent runs when button 2 on the oculus controller is released. This event will only run on an object that is being grabbed by the hand that is holding the controller.Note: This event will only run on an object that is being grabbed by the hand that is holding the controller.
Send event to objectSend event [myevent] to [self] with [param]Object: The object that the event is sent to param: The parameters the event will receiveSends a custom event to an object variable. The event will be received by the object that is being referenced by the object variable.
Send event with delaySend event [myevent] to [self] after [number] secondsObject: The object the event is sent to number: The number of seconds to delaySends a custom event to an object variable, with a set delay. The event will be received by the object that is being referenced by the object variable.
Cancel sending event with delayCancel sending event [myevent] to [self]Object: The object to stop sending a custom event toCancels a custom event from being sent.
Connections
Connect to eventconnect [self] [triggerenter] to local event [enter]object: The object the where the non-local script event fires event: The event in the non-local script event: The event in the local script that the non-local script should connect to Connects an event in another object to an event in the local script, so when the event in the other object is triggered, the event in the local script is triggered too.Note: This is useful for connecting multiple triggers in a script to one or multiple events in order to make a triggerable system.
Motion Tab
Instant Motion
Move toaction [moveto with [vector 1 / 0 / 0]] on [self]vector: The position in world space that the object moves to object: The object that the motion applies toInstantly moves the object to the coordinates provided.Note: The object being manipulated must be marked as "Interactive" or "Animated" in the properties panel of the object.
Move byaction [move with [vector1 / 0 / 0]] on [self]vector: The direction and distance the object will move by object: The object that the motion applies toInstantly moves the object relative to its current position by adding the vector to the current position.
Rotate toaction [rotateto with [rotation 90 / 0 / 0]] on [self]rotation: The angle the object will rotate to object: The object that the motion applies toInstantly rotates the object to the rotation provided.
Rotate byaction [rotate with [rotation 90/ 0 / 0]] on [self]rotation: The angle the object will rotate by object: The object that the motion applies toInstantly rotates the object by adding the supplied rotation to the current rotation.
Scale toaction [scale with [vector 1 / 0 / 0]] on self]]vector: The size the object will scale to object: The object that the motion applies toInstantly sets the scale to the value provided.
Motion Over Time
Move to over timeaction [moveto with [vector 1 / 0 / 0] over [number {1} sec]] on [self]vector: The positon in world space that the object moves to number: The number of seconds it takes to move object: The object that the motion applies to Moves the object along a line from its current position to a new coordinate over the given time.
Move by over timeaction [move with [vector 1 / 0 / 0] over [number {1} sec]] on [self]vector: The direction and distance the object will move by number: The number of seconds it takes to move object: The object that the motion applies toMoves the object along a line from its current position to a new coordinate that is the sum of the current position and the given coordinate, over the given time.
Rotate to over timeaction [rotateto with [rotation 90 / 0 / 0] over [number {1} sec]] on [self]rotation: The angle the object will rotate to number: the number of seconds it takes to rotate object: The object that the motion applies toRotates the object from its current rotation to the given rotation over the given time.
Rotate by over timeaction [rotate with [rotation 90 / 0 / 0] over [number {1} sec]] on [self]rotation: The angle the object will rotate by number: the number of seconds it takes to rotate object: The object that the motion applies toRotates the object from its current rotation by the given rotation over the given time.
Scale to over timeaction [scale with [vector 1/ 1/ 1] over [number {1} sec]] on [self]vector: The size the object will scale to number: the number of seconds it takes to scale object: The object that the motion applies toScales the object from its current scale to the given scale over the given time.
Player Motion
Respawn playeraction [respawn with [param]] on [self]playerid: The player that will be respawned object: The spawn point to respawn them toTeleports a player to a spawn point.
Physical Motion
Disable object physical motiondisable [self] physical motionobject: The object that physical motion is being disabled onLocks a physics object in place. Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Enable object physical motionenable [self] physical motionobject: The object that physical motion is being enabled onUnlocks a physics object, allowing it to be moved.Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Pushaction [+Velocity with [vector 1/ 1/ 1]] on [self]vector: The velocity being added object: The object that physical motion is being applied toThe object's velocity becomes equal to its current velocity, plus the given velocity.Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Push with massaction [+impulse with [vector 1/ 0/ 0]] on [self]vector: The velocity being added object: The object that physical motion is being applied toThe object's velocity becomes equal to its current velocity, plus the given velocity divided by the object's mass (heavier objects have their velocity adjusted less).Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Push in local spaceaction [+VelLocal with [vector 1/ 0/ 0]] on [self]vector: The velocity being added object: The object that physical motion is being applied toThe given velocity is rotated to the object's rotation, then a Push runs (x becomes left/right, y becomes above/below, z becomes forward/backward).Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Push in local space with massaction [+ImpLocal with [vector 1/ 0 / 0]] on [self]vector: The velocity being added object: The object that physical motion is being applied toThe given velocity is rotated to the object's rotation, then a Push with Mass runs (x becomes left/right, y becomes above/below, z becomes forward/backward).Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Spin action [+AngVel with [vector 1/ 0/ 0]] on [self]vector: The angular velocity being added object: The object that physical motion is being applied toThe object's angular velocity becomes equal to its current angular velocity, plus the given angular velocity.Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Spin in local spaceaction [+AngVelLocal with [vector 1/ 0/ 0]] on [self]vector: The angular velocity being added object: The object that physical motion is being applied toThe given velocity is rotated to the object's current rotation, then a Spin runs (x becomes pitch, y becomes yaw, z becomes roll).Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Stop physical motionstop physical motion [self]object: The object that the physical motion is being stopped onThe object's velocity and angular velocity both become zero.Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Launch from objectaction [LaunchFrom with [self] [number {10}]] on [self]object: The object whose position and direction will be used to launch from number: The speed to launch it at object: The object that will be launchedMakes the object become owned by the same owner of the "launch from" object (i.e. object specified by the first parameter), sets the position and rotation of the object to match that of the "launch from" object, and then sets the object's velocity to match its forward direction with a magnitude (speed) equal to the value of the second parameter.Note: The object being manipulated must be marked as "Interactive" with "Physics" in the properties panel of the object.
Actions Tab
Object
Show objectshow [self]object: The object that will turn visibleMakes object visible in your world.Note: This will currently also affect collisions on an object. The object will be made collidable.
Hide objecthide [self]object: The object that will turn hiddenHides the object in your world.Note: This will currently also affect collisions on an object. The object will have collisions turned off.
Paint objectaction color with [color 1/ 0/ 0] on [self]color: The rgb color to paint the object with object: The object that will be paintedSets the color of the object.
Enable objectenable [self]object: The trigger that will be enabledEnables a trigger's ability to detect people or objects. This can only be used on triggers.
Disable objectdisable [self]object: The trigger that will be disabledDisables a trigger's ability to detect people or objects. This can only be used on triggers.
Set simulatedaction [setsimulated with boolean {true/false}] on [self]boolean: The true or false value that the simulated property will be set to object: The object that will have its simulation setEnables or disables the "simulated" property. If off, the object cannot move.
Set gravityaction [setgravity with boolean {true/false}] on [self]boolean: The true or false value that the gravity property will be set to object: The object that will have its simulation setEnables or disables gravity simulation on this object.If on, the object will fall to the floor. If off, it wil act like it's floating in space.
TextDisplay textaction [display with [number {1}] on [self]string/number: The value the text gizmo will display object: The text gizmo that displays the string/numberSets the displayed text in the text gizmo.
Animation
Play animationplay animation on [self]object: The object that will play its animationPlays the object's animation.
Pause animationpause animation on [self]object: The object that will pause its animationPauses the object's animation.
Stop animationstop animation on [self]object: The object to stop its animation
Sound
Play soundplay sound on [self]object: The sound gizmo that will playPlays a sound gizmo.Note: A sound must be stopped before it can be played again.
Pause soundpause sound on [self]object: The sound gizmo that will pausePauses a sound gizmo.Note: A sound must be stopped before it can be played again.
Stop soundstop sound on [self]object: The sound gizmo that will stopStops a sound gizmo.Note: A sound must be stopped before it can be played again.
Particles and Trails
Play visual fxplay visual effects on [self]object: The visual effect gizmo that will playPlays a visual effects gizmo.
Stop visual fxstop visual effects on [self]object: The visual effect gizmo that will stopStops a visual effects gizmo.
World
Reset world statereset world stateResets the world back to its inital state.
Math
Logic
"=="[a] == [b]"true" if both values are the same.
!=[a] != [b]"true" if both values are not same.
less than symbol [a] [b]"true" if the first value is less than the second value
> [a] > [b]"true" if the first value is greater than the second value
and[a] and [b]"true" if both values are true.
notnot [a]toggles a boolean value from true to false, or false to true. (I think this correct?)
or[a] or [b]"true" if one of the values is true.
Basic Operations
"+"[a] + [b]Returns the sum of two numbers.
- [a] - [b]Returns the difference of two numbers.
* [a] * [b]Returns the result of two multiplied numbers
/ [a] / [b]Returns the result of the first number divided by the second number.
% [a] % [b]Returns the "remainder" of the first number divided by the second number. Useful for making counters that count up to a certain number and then go back to 0.
Basic Math
absabs [n]Returns the positive value of a number. So, abs -10 = 10 and abs 3 = 3.
ceilceil [n]Rounds a decimal number up to the next largest whole number.
clampclamp [value] [min] [max]If the value is less than the smallest number, return the smallest number. If the value is larger than the biggest number, return the biggest number. Otherwise return the value.
floorfloor [n]Rounds a decimal number down to the next smallest whole number.
fracfrac [n]
lerplerp [from] [to] [alpha]Given a minimum number, maximum number, and an interpolated value between those numbers, lerp will return a value that represents the point of the interpolated value.
maxmax [a] [b]Returns the biggest number
minmin [a] [b]Returns the smalles number
sqrtsqrt [n]Returns the square root of a number
Advanced Math
powpow [number] [power]
coscos [radians]Returns the cosine value of a number, from -1.0 to 1.0.
sinsin [radians]Returns the sine value of a number, from -1.0 to 1.0.
tantan [radians]
acosacos [radians]
asinasin [radians]
atan2atan2 [y] [x]
expexp [power]
log10log10 [number]
random number with decimalsrandom between [min] and [max]Returns a value that can contain fractional decimals, between the first number and the second number.Note: This is inclusive of the [min] value and inclusive of the [max] value.
random numberrandom integer between [min] and [max]Returns a whole number value, between the first number and the second number.Note: This is inclusive of the [min] value and exclusive of the [max] value.
2d perlin noise2d perlin noise [x] [y]Returns a number value based on the perlin noise algorithm.
Object Transformation
position of objectposition of [o]
rotation of objectrotation of [o]
scale of objectscale of [o]
velocity of objectvelocity of [o]
forward direction of objectforward direction of [object]
upward direction of objectupward direction of [object]
Vector Math
new vector from xyznew vector [x] [y] [z]
x of vectorx of [vector]
y of vectory of [vector]
z of vectorz of [vector]
normalizenormalize [vector]
dotdot [a] [b]
crosscross [a] [b]
distance todistance from [a] to [b]
magnitude ofmagnitutde of [vector]
reflectreflect [vector]
new rotation from xyznew rotation [pitch] [yaw] [roll]
look atlook towards [forward] with up [up]
Color
new color from rgbnew color [r] [g] [b]
rgb to hsvconvert rgb to hsv [color]
hsv to rgbconvert hsv to rgb [color]
get object colorcolor of [o]
Player
Position of player[head] position of [player]Can specify head, torso, left hand, right hand, and foot position of a player.
Forward of player[head] forward of [player]Can specify head, torso, left hand, right hand, and foot forward of a player.
Name of playername of [player]Returns the username of a player.
Text
Length of stringlength of [string]Returns the length of a string.
Variable as string[string] as stringConverts other variables that aren't strings into strings. This is useful when concatenating values that aren’t strings together.
Values
set toset [variable] to [value]
Debuggingdebug printdebug print [value]
Value Input
self(self)Represents the object that the script is attached to.
number input(number [0])A number value.
boolean input[boolean [false])A boolean value.
vector input(vector [0] [0] [0])A vector3 value.
rotation input(rotation [0] [0] [0])A rotation value.
color input(color [1] [1] [1])A color value.
string input(string [.])A string value.

Was this answer helpful?