SimLab Composer’s Training Builder uses Lua scripting language. Our API allows users to create Lua scripts for their specific needs, making the tool a dynamic platform for creativity and innovation.
Lua scripting in SimLab Training Builder enables advanced users to create complex, feature-rich experiences beyond default capabilities. It allows precise customization of training scenarios with unique functionalities for immersive outcomes, offering limitless creativity.
Lua Scripting is only available in the Ultimate edition of SimLab Composer 12.1 or later and is not included in SimLab VR Studio.
To execute a Lua script in SimLab Training Builder, create a ‘Run Script’ node graph by right-clicking and selecting ‘Run Script’. This node allows Lua script input and must be linked into your graph execution flow.
print
FunctionThe print("Hello World!")
function is crucial for script writing and testing in Lua. It tracks data flow and variable states, aids in issue identification, and acts as a simple logging system for debugging and understanding code behavior.
Variable
, variable
, and VARIABLE
are all considered different identifiers in Lua.;
at the end of each statement.--
at the start of the line. For commenting out multiple lines, start with --[[
on the first line and end with ]]
on the final line.Please be aware that improper use of Lua scripting can lead to unexpected crashes in SimLab VR Viewer. Always test your scripts thoroughly before running them in production. If you encounter consistent crashes, consider reaching out to the SimLab community or support for assistance. Your understanding and caution are appreciated. Happy scripting!
Represents a Lua Manager for SimLab VR Viewer.
Find nodes in the scene by name.
(string)
The name of the nodes to search for.
Array<ASimLabTransformNode>
:
An array of nodes matching the given name.
-- Find all Box objects in scene
BoxsArray = SimLabUtils:FindNodesByName("Box")
Find nodes in the scene by attribute name.
(string)
The name of the attribute to search for.
Array<ASimLabTransformNode>
:
An array of nodes with the specified attribute.
-- Find all airplane objects in scene
AirPlanesArray = SimLabUtils:FindNodesByAttribute("AirPlane")
Find animation sequences in the scene by name.
(string)
The name of the animation sequences to search for.
Array<ASimLabAnimationSequence>
:
An array of animation sequences matching the given name.
-- Assuming that Sequence_1 exists.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:SetPlayRange(0, 100)
Find scene states in the scene by name.
(string)
The name of the scene states to search for.
Array<ASimLabSceneState>
:
An array of scene states matching the given name.
local SceneStates = SimLabUtils:FindSceneStatesByName("Mid") -- Replace "Mid" with the name of your scene state.
local SceneState = SceneStates[1]
print(SceneState:GetSceneStateName())
SceneState:Apply()
Import a VR package from a path or URL with a specified transform into the current scene.
(string)
The path or URL of the VR package.
(FTransform)
The transform to apply during import.
local nodes = SimLabUtils:FindNodesByName("3DBox")
if nodes and nodes[1] then
-- Get the target transform
local targetTransform = nodes[1]:GetNodeGlobalTransform()
print(targetTransform)
-- Import the VR package with the correct file path
SimLabUtils:ImportVRPackage("C:/Users/YOUR_USERNAME/Desktop/Box.vrpackage", targetTransform)
-- Note: Replace "C:/Users/YOUR_USERNAME/Desktop/Box.vrpackage" with the actual path to your .vrpackage file.
else
print("Error: Node '3DBox' not found.")
end
Get a variable by name.
(string)
The name of the variable to retrieve.
UEventsVariable
:
The variable with the specified name.
local NumVariable = SimLabUtils:GetVariableByName("num") -- Replace "num" with the name of your variable.
NumVariable:SetNumberValue(num + 2)
Get the first player controller.
ASimLabController
:
The first player controller.
-- Retrieve the first player controller.
local Player = SimLabUtils:GetFirstPlayerController()
local CameraLocation = Player:GetUserLocation()
print(CameraLocation.x)
Create a new HTTP request.
USimLabLuaHttpRequest
:
A new HTTP request object.
-- New Rest API request object
HttpRequest = SimLabUtils:NewHttpRequest()
Create a new JSON object.
USimLabLuaJsonObject
:
A new JSON object.
-- Create a new JSON object
JSON_Object = SimLabUtils:NewJsonObject()
Create a new JSON value.
USimLabLuaJsonValue
:
A new JSON value.
-- Create a new JSON value
local OutJSONArray1 = SimLabUtils:NewJsonValue()
Represents a 3D Object Node in Lua.
Get the material associated with this 3DObject SceneNode.
ASimLabMaterial
:
The material for this 3DObject SceneNode.
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the SceneNode name that contains a material.
local Node = Nodes[1] -- Get first SceneNode
local NodeMaterial = Node:GetMaterial()
print(NodeMaterial:GetMaterialName())
Set the material for an 3DObject SceneNode.
(ASimLabMaterial)
The new material to set.
-- Swap materials between two 3DObjects
local Nodes = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the SceneNode name that contains a material.
local Box = Nodes[1]
local Nodes2 = SimLabUtils:FindNodesByName("3DSphere") -- Replace "3DSphere" with the SceneNode name that contains a second material.
local Sphere = Nodes2[1]
local BoxMaterial = Box:GetMaterial()
local SphereMaterial = Sphere:GetMaterial()
print(BoxMaterial:GetMaterialName())
print(SphereMaterial:GetMaterialName())
Box:SetMaterial(SphereMaterial)
Sphere:SetMaterial(BoxMaterial)
Represents a 3D Sound Node in Lua.
Toggle the playback state of the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the Attribute of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:ToggleState()
else
print("No Sound node found")
end
Play the sound, restarting if already playing, or resuming if previously stopped.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the Attribute of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Play()
else
print("No Sound node found")
end
Stop the sound playback.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the Attribute of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Stop()
else
print("No Sound node found")
end
Seek to a specific time in the sound playback.
(number)
The time to seek to.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the Attribute of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Seek(3) -- Seek to 3 seconds
else
print("No Sound node found")
end
Play the sound for the specified duration or until it ends.
(number)
The duration to play the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the Attribute of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:PlayDuration(2) -- Play for 2 seconds
else
print("No Sound node found")
end
Represents a Player Controller (The object that's used to control the player's character) in Lua.
Get the camera's transform.
FTransform
:
The camera's transform.
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
print(tostring(CameraTransform))
local CameraRotation = CameraTransform.Rotation
print(tostring(CameraRotation))
local CameraLocation = CameraTransform.Translation
print(tostring(CameraLocation))
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3
Point the controller to a specified SceneNode.
(ASimLabTransformNode)
The SceneNode to point to.
local Controller = SimLabUtils:GetFirstPlayerController()
local Nodes = SimLabUtils:FindNodesByAttribute("Target") -- Replace "Target" with the name of your attribute.
Controller:PointToNode(Nodes[1])
Remove the pointed object association from the controller.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:RemovePointToNode()
Teleport the controller to a specified location and orientation.
(FVector)
The eye position to teleport to.
(FRotator)
The rotation of the view.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:TeleportToView(UE.FVector(0, 0, 200), UE.FRotator(0, 180, 0))
Teleport the controller to a specified location.
(FVector)
The eye position to teleport to.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:TeleportToLocation(UE.FVector(0, 0, 200))
Represents a Lua HTTP Request in Lua.
Set the request body with a JSON object. In the example we create a new JSON object and set the username and password of the user, then we assign it to the new HTTP request using
(USimLabLuaJsonObject)
The JSON object to set as the request body.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetStringField("username", "SimLab123")
JSON_Object:SetStringField("password", "Pass123")
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetRequestBody(JSON_Object)
Process the HTTP request. Parameters allowed:
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
HttpRequest:ProcessRequest()
Add a header to the HTTP request. In the example we add the api token key we need to use to access the Rest API.
(string)
The name of the header field.
(string)
The value of the header field.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:AddHeader("api_key", "9s8ahg9as8hasdg8kavkch")
Set the endpoint for the HTTP request. In the example we set the URI of the currency exchange API as our endpoint.
(string)
The endpoint URL for the request.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
Set the HTTP verb (e.g., GET, POST) for the request.
(string)
The HTTP verb for the request.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
Returns a reference of a JSON object containing the body of the response from the endpoint. In the example we assume we did the steps for OnResponse and we received a response from the endpoint.
USimLabLuaJsonObject
:
The JSON response object.
function OnResponse()
print("Response received")
HttpResponse = HttpRequest:GetResponse()
end
Event handler for the HTTP request response. Assigns the function we want to call once we receive a reply to our HTTP request. In the example we assign the OnResponse function defined as the delegate function to call once we receive a reply after sending the HTTP request. Parameters for Add are:
(USimLabLuaHttpRequest)
: The HTTP request that triggered the response.
function OnResponse()
print("Response received")
end
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
HttpRequest.OnResponse:Add(HttpRequest, OnResponse)
Represents a JSON Object in Lua.
Adds a new string field to the JSON structure. In the example we added a username field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetStringField("username", "SimLab123")
Adds a new number field to the JSON structure. In the example we added an age field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetNumberField("age", 21)
Adds a new boolean field to the JSON structure. In the example we added an in-stock field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetBoolField("instock", true)
Adds a new JSON object field to the JSON structure. In the example we added a set of usernames in a new field with its values.
(string)
The name of the field.
(USimLabLuaJsonObject)
The object value to set.
Usernames = SimLabUtils:NewJsonObject()
Usernames:SetStringField("username", "SimLab123")
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetObjectField("Usernames", Usernames)
Set an array field in the JSON object.
(string)
The name of the field.
(Array<USimLabLuaJsonValue>)
The array value to set.
JsonArray1 = {JSONVal1, JSONVal2, JSONVal3}
local OutJSONArray1 = SimLabUtils:NewJsonValue()
OutJSONArray1:SetArray(JsonArray1)
JsonArray = {OutJSONArray1, OutJSONArray1}
local JsonArg = SimLabUtils:NewJsonObject()
JSON_Object:SetArrayField("array_arg", JsonArray)
Get a JSON Object field from the JSON object.
(string)
The name of the field.
USimLabLuaJsonObject
:
The object value of the field.
Usernames = SimLabUtils:NewJsonObject()
Usernames:SetStringField("username", "SimLab123")
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetObjectField("Usernames", Usernames)
UsernamesSet = JSON_Object:GetObjectField("Usernames")
Returns an Array Referencing all JSON Objects inside the specified field.
(string)
The name of the field.
Array<USimLabLuaJsonValue>
:
The array value of the field.
local Iterate = RestAPI:GetResponse()
local IterateData = Iterate:GetArrayField("data")
Represents a Lua JSON Value in Lua.
Returns an Array of JSON Values containing the contents of the specified index from the JSON Value array.
Array<USimLabLuaJsonValue>
:
The value as an array of JSON values.
local IterateData = Iterate:GetArrayField("data")
local FirstIndex = IterateData[1]:AsArray()
Returns a JSON Object containing the contents of the specified index from the JSON Value array.
USimLabLuaJsonObject
:
The value as a JSON object.
local IterateData = Iterate:GetArrayField("data")
local FirstIndex = IterateData[1]:AsObject()
Set this value as an array of JSON values.
(Array<USimLabLuaJsonValue>)
The array of JSON values to set.
local JSONVal1 = SimLabUtils:NewJsonValue()
JSONVal1:SetObject(JsonArg11)
local JSONVal2 = SimLabUtils:NewJsonValue()
JSONVal2:SetObject(JsonArg12)
local JSONVal3 = SimLabUtils:NewJsonValue()
JSONVal3:SetObject(JsonArg13)
JsonArray1 = {JSONVal1, JSONVal2, JSONVal3}
local OutJSONArray1 = SimLabUtils:NewJsonValue()
OutJSONArray1:SetArray(JsonArray1)
Set this value as a JSON object.
(USimLabLuaJsonObject)
The JSON object to set.
local JsonArg11 = SimLabUtils:NewJsonObject()
JsonArg11:SetStringField("name", "reem1")
JsonArg11:SetStringField("gender", "Femail1")
JsonArg11:SetStringField("job_title", "Software engineer1")
local JSONVal1 = SimLabUtils:NewJsonValue()
JSONVal1:SetObject(JsonArg11)
Represents a Material in SimLab VR Viewer.
Get the name of the material.
string
:
The name of the material.
-- Assuming Node1 exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your SceneNode.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
print(BoxMaterial:GetMaterialName())
else
print("Node not found")
end
Get the type of the material.
string
:
The type of the material.
-- Assuming Node1 exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your SceneNode.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
print(BoxMaterial:GetMaterialType())
else
print("Node not found")
end
Set the Linear color of the material.
(FLinearColor)
The new color to set.
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your SceneNode.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetMaterialColor(UE.FLinearColor(1, 0, 0)) --FLinearColor(Red, Green, Blue) Values Between 0 and 1.
else
print("Node not found")
end
Get the color of the material.
FLinearColor
:
The color of the material.
-- Assuming Node exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
local Color = BoxMaterial:GetMaterialColor()
Color.R = math.random() --Random value for Color.Red
Color.B = math.random() --Random value for Color.Blue
print(tostring(Color))
BoxMaterial:SetMaterialColor(Color)
else
print("Node not found")
end
Set the alpha (transparency) of the material.
(number)
The alpha value to set.
-- Assuming Node exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetMaterialAlpha(0.5) --50% opacity
Get the alpha (transparency) of the material.
number
:
The alpha value of the material.
-- Assuming Node exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
local Alpha = BoxMaterial:GetMaterialAlpha()
print(Alpha)
else
print("Node not found")
end
Set Density of Physical Material Data in Material.
(number)
The density value to set.
-- Assuming Node exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetDensity(0.5)
else
print("Node not found")
end
Get Density of Physical Material Data in Material.
number
:
The density value of the material.
-- Assuming Node exists
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
local Density = BoxMaterial:GetDensity()
print(Density)
else
print("Node not found")
end
Set the friction of Physical Material Data in Material.
(number)
The friction value to set.
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetFriction(0.5)
else
print("Node not found")
end
Get the friction of Physical Material Data in Material.
number
:
The friction value of the material.
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
local Friction = BoxMaterial:GetFriction()
print(Friction)
else
print("Node not found")
end
Set the restitution (bounce) of Physical Material Data in Material.
(number)
The restitution value to set.
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetRestitution(0.5)
else
print("Node not found")
end
Get the restitution (bounce) of Physical Material Data in Material.
number
:
The restitution value of the material.
local Boxs = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your 3DObject.
local Box = Boxs[1]
if Box then
local BoxMaterial = Box:GetMaterial()
local Restitution = BoxMaterial:GetRestitution()
print(Restitution)
else
print("Node not found")
end
Copy material preoperties from OtherMaterial.
(any)
Creates a copy of this material.
ASimLabMaterial
:
The new copy material.
Represents a Quiz in SimLab VR Viewer.
Activate the quiz associated with this node.
--Assuming QuizButton node exists
local Nodes = SimLabUtils:FindNodesByName("QuizButton")
Nodes[1]:ActivateQuiz()
Represents a Scene State in SimLab VR Viewer.
Extends ASimLabAnimationSequence
Represents an Animation Sequence in SimLab VR Viewer.
Get the name of the animation sequence.
string
:
The name of the animation sequence.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
print(Sequence:GetSequenceName())
Check if the animation sequence is looping.
boolean
:
Whether the animation is looping.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsLooping() then
print("The Animation is looping")
else
print("The Animation is NOT looping")
end
Set whether the animation sequence is looping.
(boolean)
Whether the animation should loop.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsLooping() then
print("Animation looping:True")
else
Sequence:SetIsLooping(true)
print("Animation looping:False->True")
end
Check if the animation sequence is swinging.
boolean
:
Whether the animation is swinging.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
print(tostring(Sequence:IsSwinging()))
Set whether the animation sequence is swinging.
(boolean)
Whether the animation should swing.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:SetIsSwinging(true)
Set the play rate of the animation sequence.
(number)
The new play rate.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
Sequence:SetPlayRate(0.5)
else
print("Sequence NOT found")
Get the play rate of the animation sequence.
number
:
The play rate of the animation.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
PlayRate = Sequence:GetPlayRate()
print(tostring(PlayRate))
else
print("Sequence not found")
end
Get the start frame of the full animation range.
number
:
The start frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
print(Sequence:GetFullRangeStartFrame())
else
print("Sequence not found")
end
Get the end frame of the full animation range.
number
:
The end frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
print(Sequence:GetFullRangeEndFrame())
else
print("Sequence not found")
end
Set the play range of the animation sequence.
(number)
The start frame of the play range.
(number)
The end frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with name of your sequence.
local Sequence = Sequences[1]
if Sequence then
local Start =Sequence:GetFullRangeStartFrame()
local End = Sequence:GetFullRangeEndFrame()
Sequence:SetPlayRange(Start, End)
print(End-Start)
else
print("Sequence not found")
end
Get the start frame of the play range.
number
:
The start frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
print(Sequence:GetPlayRangeStartFrame())
else
print("Sequence not found")
end
Get the end frame of the play range.
number
:
The end frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence then
print(Sequence:GetPlayRangeEndFrame())
else
print("Sequence not found")
end
Start playing the animation from the beginning.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:PlayFromStart()
Start playing the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:Play()
Continue playing the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:Continue()
Reverse the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:Reverse()
Reverse the animation from the end frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:ReverseFromEnd()
Flip the direction of the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:Flip()
Stop playing the animation.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:Stop()
Seek to a specific frame in the animation.
(number)
The frame to seek to.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequnce:Seek(54.555)
Check if the animation is currently playing.
boolean
:
Whether the animation is playing.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsPlaying() then
Sequence:Stop()
print("Playing -> Stop")
else
Sequence:PlayFromStart()
print("Stop -> Playing")
end
Check if the animation is currently reversing.
boolean
:
Whether the animation is reversing.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsReversing() then
Sequence:Stop()
print("Reversing -> Stop")
else
Sequence:ReverseFromEnd()
print("Stop -> Reversing")
end
Represents a Scene Node in SimLab VR Viewer.
Get the parent node of this transform node.
ASimLabTransformNode
:
The parent node.
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your SceneNode.
if node[1] then
local parentNode = node[1]:GetParentNode()
print(parentNode:GetNodeName())
else
print("node not Found !")
end
Get the initial parent node of this transform node.
ASimLabTransformNode
:
The initial parent node.
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your SceneNode.
if node[1] then
local initialParentNode = node[1]:GetInitialParentNode()
print(initialParentNode:GetNodeName())
else
print("node not Found !")
end
Set the parent node of this transform node.
(ASimLabTransformNode)
The new parent node.
-- Assuming childNode and parentNode exists
local childNode = SimLabUtils:FindNodesByAttribute("child") -- Replace "child" with the Attribute of your child SceneNode.
local parentNode = SimLabUtils:FindNodesByAttribute("parent") -- Replace "parent" with the Attribute of your parent SceneNode.
childNode[1]:SetParentNode(parentNode[1]) --InAttachRules:"KeepWorld" is Default if not assigned
print(parentNode[1]:GetNodeName())
Set the parent node of this transform node.
(ASimLabTransformNode)
The new parent node.
(string
= ""
)
Attachment rules (KeepWorld, KeepRelative, SnapToTargetWithScale, SnapToTarget).
-- Assuming node exists
local childNode = SimLabUtils:FindNodesByAttribute("child") -- Replace "child" with the Attribute of your child SceneNode.
local parentNode = SimLabUtils:FindNodesByAttribute("parent") -- Replace "parent" with the Attribute of your parent SceneNode.
childNode[1]:SetParentNode(parentNode[1],"KeepWorld")
--InAttachRules Types:(Default:"KeepWorld", "KeepRelative", "SnapToTargetWithScale", "SnapToTarget")
print(parentNode[1]:GetNodeName())
Reset this node to its initial parent node.
(string
= ""
)
Attachment rules (optional).
-- Assuming node exists
local nodes = SimLabUtils:FindNodesByName("node_1")
local node = nodes[1]
if node then
node:ResetToInitialParentNode()--InAttachRules Types:(Default:"KeepWorld", "KeepRelative", "SnapToTargetWithScale", "SnapToTarget")
print(node:GetInitialParentNode():GetNodeName())
else
print("node not Found !")
end
Get a set of children nodes of this transform node.
Array<ASimLabTransformNode>
:
A set of children nodes.
-- Assuming Parent exists
local Nodes = SimLabUtils:FindNodesByName("Parent")
local children = Nodes[1]:GetChildrenNodes()
for counter, child in ipairs(children) do
print("Child " .. counter, child)
end
Get a set of descendant nodes of this transform node (children and children's children).
Array<ASimLabTransformNode>
:
A set of descendant nodes.
-- Assuming Parent exists
local Nodes = SimLabUtils:FindNodesByName("Parent") -- Replace "Parent" with the name of your SceneNode.
local descendants = Nodes[1]:GetDescendantNodes()
for counter, child in ipairs(descendants) do
print("descendant " .. counter, child)
end
Get an array of ancestor nodes of this transform node.
(boolean
= false
)
Include this node in the result (Default:"false","true").
Array<ASimLabTransformNode>
:
An array of ancestor nodes.
local Nodes = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your SceneNode.
local Ancestors =Nodes[1]:GetAncestorNodes()
for counter, Ancestor in ipairs(Ancestors)
do print("Ancestor " .. counter, Ancestor:GetNodeName())
end
Get an attribute of this transform node by name.
(string)
The name of the attribute.
string
:
The value of the attribute.
-- Assuming node Box exists
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
local Box = Nodes[1]
local AttriblueValue = Box:GetNodeAttribute("test") -- Replace "test" with the name of your Attribute.
print(AttriblueValue)
Get an attribute from a specific category of this transform node by name.
string
:
The value of the attribute.
-- Assuming node Box exists
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
local Node = Nodes[1]
local AttriblueValue = Node:GetNodeAttributeFromCategory("Name","Category")
print(AttriblueValue)
Set an attribute of this transform node by name.
-- Assuming Box exists
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
Node =Nodes[1]
local attributeName = "Color"
local attributeValue = "Red"
Node:SetNodeAttribute(attributeName, attributeValue)
print(Node:GetNodeAttribute(attributeName))
SetNodeAttributeInCategory(attributeName, attributeValue, Category) Set an attribute in a specific category of this transform node by name.
(string)
The name of the attribute.
(string)
The value to set.
(string)
The category of the attribute.
* -- Assuming Box exists
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
Node =Nodes[1]
local attributeName = "Color"
local attributeValue = "Red"
local Category = "Appearance"
Node:SetNodeAttributeInCategory(attributeName, attributeValue,Category)
print(Node:GetNodeAttributeFromCategory(attributeName,Category))
Check if this transform node has a specific attribute by name.
(string)
The name of the attribute.
boolean
:
Whether the node has the attribute.
local node = SimLabUtils:FindNodesByName("Name") -- Replace "Name" with the name of your SceneNode.
local hasAttribute = node[1]:NodeHasAttribute("test") -- Replace "test" with the name of your Attribute.
print(tostring(hasAttribute))
Check if this transform node has an attribute in a specific category by name.
boolean
:
Whether the node has the attribute in the category.
-- Assuming node attriblue exists
local nodes = SimLabUtils:FindNodesByName("Name") -- Replace "Name" with the name of your SceneNode.
local attributeName = "Color"
local attributeCategory = "Visuals"
local hasAttributeInCategory = nodes[1]:NodeHasAttributeInCategory(attributeName, attributeCategory)
print(hasAttributeInCategory)
Set the glow state of this node.
(boolean)
Whether to set the node as glowing.
-- Assuming Box exists
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
node[1]:SetNodeGlowState(true)
print("Node glow state set to enabled.")
Make this node glow.
-- Highlight first Box
nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
if nodes[1] then
nodes[1]:GlowNode()
else
print("Node Has Not Found")
end
Stop glowing this node.
-- Assuming Box exists
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
node[1]:StopGlowNode()
print("Node glow Stopped.")
Check if this node is currently glowing.
boolean
:
Whether the node is glowing.
-- Assuming Box exists
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
if node[1]:IsNodeGlowing() then
print("true")
else
print("false")
end
Set the visibility state of this node.
(boolean)
Whether to set the node as visible.
-- Hide first Box
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
if node[1] then
node[1]:SetNodeVisibility(false)
else
print("Node Not Found")
end
Check if this node is currently visible.
boolean
:
Whether the node is visible.
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your node.
-- Check if the node is currently visible
local isVisible = node[1]:IsNodeVisible()
print("Is the node visible? " .. tostring(isVisible))
Show this node.
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
if node then
node[1]:ShowNode()
print("Node is now visible.")
else
print("Node Not Found")
end
Hide this node.
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
if node then
node[1]:HideNode()
print("Node is now hidden.")
else
print("Node Not Found.")
end
Delete this node.
local Nodes = SimLabUtils:FindNodesByName("Name") -- Replace "Name" with the name of your node.
if Nodes then
Nodes[1]:DeleteNode()
print("Node has been deleted.")
else
print("Node Not Found.")
end
Make Instance of this node.
ASimLabTransformNode
:
The new instance node.
-- Assuming Node_1 exists
local Nodes = SimLabUtils:FindNodesByName("Node_1") -- Replace "Node_1" with the name of your node.
local Node = Nodes[1]
local NodeCopy = Node:MakeNodeInstance()
Make copy of this node.
ASimLabTransformNode
:
The new copy node.
-- Assuming Node_1 exists
local Nodes = SimLabUtils:FindNodesByName("Node_1") -- Replace "Node_1" with the name of your node.
local Node = Nodes[1]
local NodeCopy = Node:MakeNodeCopy()
Get the global transform of this node.
FTransform
:
The global transform.
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
local Box = Nodes[1]
Box:AnimatedSetNodeLocalLocation(UE.FVector(0.5), 1)
Box:AnimatedSetNodeLocalScale(UE.FVector(0.2), 1)
Box:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
local WorldTransform = Box:GetNodeGlobalTransform()
print(tostring(WorldTransform))
Get the local transform of this node.
FTransform
:
The local transform.
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
local Pyramid =Nodes[1]
Pyramid:AnimatedSetNodeLocalLocation(UE.FVector(0.5), 1)
Pyramid:AnimatedSetNodeLocalScale(UE.FVector(0.2), 1)
Pyramid:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
local WorldTransform = Pyramid:GetNodeLocalTransform()
print(tostring(WorldTransform))
Get the initial global transform of this node when the scene started.
FTransform
:
The initial global transform.
-- Assuming node name is "Box"
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your SceneNode.
-- Get the initial global transform of the node
local initialGlobalTransform = node[1]:GetInitialGlobalTransform()
-- Print the initial global transform matrix
print(tostring(initialGlobalTransform))
Set the global transform of this node.
(FTransform)
The new global transform.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the initial global transform of the node
local nodeTransform = node[1]:GetInitialGlobalTransform()
node[1]:SetNodeGlobalTransform(nodeTransform)
print("Node's Global transform has been set.")
Set the relative transform of this node.
(FTransform)
The new local transform.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the local transformation of the node
local WorldTransform = node[1]:GetNodeLocalTransform()
-- Set node transformation
node[1]:SetNodeLocalTransform(transformMatrix)
-- Print confirmation
print("Node's Local transform has been set.")
Animate setting the global transform of this node.
(FTransform)
The target global transform.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("Box")
local node2 = SimLabUtils:FindNodesByName("Box2")
-- Create a transformation matrix for the target transform
local targetTransform = node2[1]:GetNodeGlobalTransform()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated global transform to the node
node[1]:AnimatedSetNodeGlobalTransform(targetTransform, duration)
-- Print confirmation
print("Node's global transform is animating over " .. duration .. " seconds.")
Animate setting the local transform of this node.
(FTransform)
The target local transform.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Create a new node object
local node = SimLabUtils:FindNodesByName("Box")
local node2 = SimLabUtils:FindNodesByName("Box")
-- Create a transformation matrix for the target transform
local targetTransform = node2[1]:GetNodeGlobalTransform()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated local transform to the node
node[1]:AnimatedSetNodeLocalTransform(targetTransform, duration)
-- Print confirmation
print("Node's Local transform is animating over " .. duration .. " seconds.")
Get the global location of this node.
FVector
:
The global location.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the global location of the node
local globalLocation = node[1]:GetNodeGlobalLocation()
-- Print the global location (x, y, z)
print("Node's global location: " .. tostring(globalLocation))
Get the local location of this node.
FVector
:
The local location.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the local location of the node
local localLocation = node[1]:GetNodeLocalLocation()
-- Print the local location (x, y, z)
print("Node's local location: " .. tostring(localLocation))
Set the global location of this node.
(FVector)
The new global location.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box = Nodes[1]
local Player = SimLabUtils:GetFirstPlayerController()
-- Assuming there is a camera in the scene
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:MakeNodeCopy()
print(tostring(NewLocation))
BoxCopy:SetNodeGlobalLocation(NewLocation)
Set the local location of this node.
(FVector)
The new local location.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes then
local Box = Nodes[1]
local locallocation = Box:SetNodeLocalLocation(UE.FVector(0.5))
else
print("Node Not Found")
end
Make this node fall to the surface.
-- Make first Box fall to the surface
local node = SimLabUtils:FindNodesByName("Box")
node[1]:FallToSurface()
Animate making this node fall to the surface.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Assuming Node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
-- Set the duration for the fall animation
local duration = 2.0 -- Fall over 2 seconds
-- Apply the animated fall to the surface
node[1]:AnimatedFallToSurface(duration)
-- Print confirmation
print("Node is animating a fall to the surface over " .. duration .. " seconds.")
Animate setting the global location of this node.
(FVector)
The target global location.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Create a new node object
local node = SimLabUtils:FindNodesByName("Box")
local node2 = SimLabUtils:FindNodesByName("Box2")
-- Create a transformation matrix for the target transform
local targetTransform = node2[1]:GetNodeGlobalLocation()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated global location to the node
node[1]:AnimatedSetNodeGlobalLocation(targetTransform, duration)
-- Print confirmation
print("Node's global transform is animating over " .. duration .. " seconds.")
Animate setting the local location of this node.
(FVector)
The target local location.
(number
= 1.0
)
The duration of the animation in seconds (optional).
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes then
local Box = Nodes[1]
Box:AnimatedSetNodeLocalLocation(UE.FVector(0.5))
else
print("Node Not Found")
end
Get the global rotation of this node.
FRotator
:
The global rotation.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the global Rotation of the node
local globalRotation = node[1]:GetNodeGlobalRotation()
-- Print the global Rotation (x, y, z)
print("Node's global Rotation: " .. tostring(globalRotation))
Get the local rotation of this node.
FRotator
:
The local rotation.
-- Assuming node Box exists
local node = SimLabUtils:FindNodesByName("Box")
-- Get the local Rotation of the node
local localRotation = node[1]:GetNodeLocalRotation()
-- Print the local Rotation (x, y, z)
print("Node's local Rotation: " .. tostring(localRotation))
Set the global rotation of this node.
(FRotator)
The new global rotation.
local Nodes = SimLabUtils:FindNodesByAttribute("Name") -- Replace "Name" with the name of your attribute
local Box= Nodes[1]
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local BoxCopy = Box:MakeNodeCopy()
BoxCopy:SetNodeGlobalRotation(CameraRotation:ToRotator())
Set the local rotation of this node.
(FRotator)
The new local rotation.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box=Nodes[1]
Box:SetNodeLocalRotation(UE.FRotator(0, -90 , 0))
Reset the node's rotation to its initial scene state.
(string
= ""
)
The type of reset ("All", "Up").
-- Reset first Box Rotation
local node = SimLabUtils:FindNodesByName("Box")
local Box = node[1]
Box:MakeNodeGrabbable(true)
Box:ResetRotation('ALL') -- (Default:"All", "Up")
Animate setting the global rotation of this node.
(FRotator)
The target global rotation.
(number
= 1.0
)
The duration of the animation in seconds (optional).
(boolean
= true
)
Whether to take the shortest path (optional).
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local BoxCopy = Box:MakeNodeInstance()
BoxCopy:AnimatedSetNodeGlobalRotation(CameraRotation:ToRotator(), 5, false)
Animate setting the local rotation of this node.
(FRotator)
The target local rotation.
(number
= 1.0
)
The duration of the animation in seconds (optional).
(boolean
= true
)
Whether to take the shortest path (optional).
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local BoxCopy = Box:MakeNodeInstance()
BoxCopy:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
Get the global scale of this node.
FVector
:
The global scale.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the global location of the node
local GlobalScale = node[1]:GetNodeGlobalScale()
-- Print the global Scale (x, y, z)
print("Node's global Scale: " .. tostring(GlobalScale))
Get the local scale of this node.
FVector
:
The local scale.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the local location of the node
local localScale = node[1]:GetNodeLocalScale()
-- Print the local Scale (x, y, z)
print("Node's local Scale: " .. tostring(localScale))
Set the global scale of this node.
(FVector)
The new global scale.
local node = SimLabUtils:FindNodesByName("Box")
node[1]:SetNodeGlobalScale(node[1]:GetNodeGlobalScale()*1.3) -- Set the box global scale to 130%
Set the local scale of this node.
(FVector)
The new local scale.
local node = SimLabUtils:FindNodesByName("Box")
node[1]:SetNodeLocalScale(node[1]:SetNodeLocalScale()*1.3) -- Set the box local scale to 130%
Animate setting the global scale of this node over duration of time.
(FVector)
The target global scale.
(number
= 1.0
)
The duration of the animation in seconds (optional).
local node = SimLabUtils:FindNodesByName("Box")
-- Animate the box global scale to 130% over duration 3 seconds
node[1]:AnimatedSetNodeGlobalScale(node[1]:GetNodeGlobalScale()*1.3 , 3)
Animate setting the local scale of this node.
(FVector)
The target local scale.
(number
= 1.0
)
The duration of the animation in seconds (optional).
local node = SimLabUtils:FindNodesByName("Box")
-- Animate the box local scale to 130% over duration 3 seconds
node[1]:AnimatedSetNodeLocalScale(node[1]:GetNodeGlobalScale()*1.3 , 3)
Cancel grabbing this node.
local node = SimLabUtils:FindNodesByName("Box")
node[1]:CancelNodeGrab()
print("The grab action for the node has been canceled.")
Set the grabbable sequence for this node.
(ASimLabAnimationSequence)
The grabbable sequence to set (optional).
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local Sequneces = SimLabUtils:FindSequencesByName("Right")
local Sequence = Sequences[1]
Box:SetGrabbableSequence(Sequence)
Show a message box on this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
title = "Test"
body = "Hello World!"
Nodes[1]:ShowMessageBox(title, body)
Check if a message box is currently shown on this node.
boolean
:
Whether a message box is shown.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes[1]:IsMessageBoxShown() then
print("A message box is currently being displayed.")
else
print("No message box is being displayed.")
end
Hide the message box on this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes[1]:IsMessageBoxShown() then
Nodes[1]:HideMessageBox()
else
print("No message box is shown.")
end
Set simulate physics to node (has to be 3D Object and enabled physics in SimLab).
(boolean)
Whether to enable simulate physics for this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
Box:SetNodeSimulatePhysics(true)
Check if simulate physics is enabled for this node.
boolean
:
Whether simulate physics is enabled.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local IsSimulatePhysics = Box:IsNodeSimulatingPhysics()
print(tostring(IsSimulatePhysics))
Align two identical nodes to each other (useful for animations with physics illusion).
(ASimLabTransformNode)
The target node to align to.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local Nodes2 = SimLabUtils:FindNodesByName("Box2")
local Box2 = Nodes2[1]
Box:AlignNodeTo(Box2)
Represents an Events Variable in SimLab VR Viewer.
The name of the variable.
Type: string
local myVariable = 10
local _anotherVar = "Hello"
The type name of the variable.
Type: string
local myNum = 42
print(type(myVar)) -- Output: "number"
local myStr = "test"
print(type(myStr)) -- Output: "string"
Change the variable's value by expression using Lua syntax.
(string)
The Lua expression to change the variable's value.
local myVar = 10
print("Node's variable value before change: " .. myVar)
myVar = 20
print("Node's variable value after change : " .. myVar)
Represents a Video Material in SimLab VR Viewer.
Toggle the playback state of the video.
local nodes = SimLabUtils:FindNodesByName("video")
node = nodes[1]
if node then
video =node:GetMaterial()
video:ToggleState() -- Call the method to toggle the state
print("Node's state has been toggled.")
else
print("Node not found.")
end
Start playing the video.
local nodes = SimLabUtils:FindNodesByName("video")
node = nodes[1]
if node then
video =node:GetMaterial()
video:Play()
Stop the video playback.
local nodes = SimLabUtils:FindNodesByName("video")
node = nodes[1]
if node then
video =node:GetMaterial()
video:Stop()
Represents a VR Camera in SimLab VR Viewer.
Check if orientation is applied when teleporting to the camera.
boolean
:
Whether orientation is applied when teleporting.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local applyOrientation = node[1]:IsApplyOrientation() -- Check if orientation is applied
if applyOrientation then
print("Orientation is applied when teleporting to the camera.")
else
print("Orientation is not applied when teleporting to the camera.")
end
else
print("Node not found.")
end
Get the teleport location of the camera.
FVector
:
The teleport location.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local teleportLocation = node[1]:GetTeleportLocation() -- Get the teleport location
print("Teleport location of the camera is:")
print("X: " .. teleportLocation.x)
print("Y: " .. teleportLocation.y)
print("Z: " .. teleportLocation.z)
else
print("Node not found.")
end
Get the teleport rotation of the camera.
FRotator
:
The teleport rotation.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local teleportRotation = node[1]:GetTeleportRotation() -- Get the teleport rotation
print("Teleport rotation of the camera is:")
print("Pitch: " .. teleportRotation.pitch)
print("Yaw: " .. teleportRotation.yaw)
print("Roll: " .. teleportRotation.roll)
else
print("Node not found.")
end