Lua Class - block

Extends sceneObject

block is a class in the Teverse Lua API that contains 15 properties, 11 methods and 3 events. block extends sceneObject.

CODE SAMPLE
--The values set in this constructor are random and may not work correctly.
local block = teverse.construct("block", {
    angularFactor = vector3(10, 10, 10),
    angularVelocity = vector3(10, 10, 10),
    colour = colour.rgb(255, 255, 255),
    linearFactor = vector3(10, 10, 10),
    mesh = "",
    metalness = 1.0,
    name = "",
    parent = sceneObject,
    position = vector3(10, 10, 10),
    rotation = quaternion,
    roughness = 1.0,
    scale = vector3(10, 10, 10),
    simulated = true,
    static = true,
    velocity = vector3(10, 10, 10),
    visible = true
})
Properties
vector3 angularFactor

CODE SAMPLE
block.angularFactor = vector3(10, 10, 10)
print(block.angularFactor) --> vector3(10, 10, 10)
vector3 angularVelocity

CODE SAMPLE
block.angularVelocity = vector3(10, 10, 10)
print(block.angularVelocity) --> vector3(10, 10, 10)
READONLY
table<string> animations

Get available animations for the loaded mesh.

CODE SAMPLE
print(block.animations) --> table<string>
colour colour

CODE SAMPLE
block.colour = colour.rgb(255, 255, 255)
print(block.colour) --> colour.rgb(255, 255, 255)
READONLY
table<joint> joints

CODE SAMPLE
print(block.joints) --> table<joint>
vector3 linearFactor

CODE SAMPLE
block.linearFactor = vector3(10, 10, 10)
print(block.linearFactor) --> vector3(10, 10, 10)
string mesh

CODE SAMPLE
block.mesh = ""
print(block.mesh) --> ""
READONLY
vector3 meshScale

How big the mesh is relative to the standard teverse unit size

CODE SAMPLE
print(block.meshScale) --> vector3(10, 10, 10)
number metalness

CODE SAMPLE
block.metalness = 1.0
print(block.metalness) --> 1.0
number roughness

CODE SAMPLE
block.roughness = 1.0
print(block.roughness) --> 1.0
vector3 scale

CODE SAMPLE
block.scale = vector3(10, 10, 10)
print(block.scale) --> vector3(10, 10, 10)
boolean simulated

When false, an object is no longer simulated and doesn't interact with other simulated objects

CODE SAMPLE
block.simulated = true
print(block.simulated) --> true
boolean static

When true, an object is unaffected by gravity and other forces, but other objects may still collide with the object

CODE SAMPLE
block.static = true
print(block.static) --> true
vector3 velocity

CODE SAMPLE
block.velocity = vector3(10, 10, 10)
print(block.velocity) --> vector3(10, 10, 10)
boolean visible

When true, this object is rendered. Note that when false this object still exists and can still be simulated.

CODE SAMPLE
block.visible = true
print(block.visible) --> true
INHERITED READONLY
vector3 absolutePosition

CODE SAMPLE
print(block.absolutePosition) --> vector3(10, 10, 10)
INHERITED READONLY
quaternion absoluteRotation

CODE SAMPLE
print(block.absoluteRotation) --> quaternion
INHERITED READONLY
number id

CODE SAMPLE
print(block.id) --> 1.0
INHERITED
string name

CODE SAMPLE
block.name = ""
print(block.name) --> ""
INHERITED
sceneObject parent

CODE SAMPLE
block.parent = sceneObject
print(block.parent) --> sceneObject
INHERITED
vector3 position

CODE SAMPLE
block.position = vector3(10, 10, 10)
print(block.position) --> vector3(10, 10, 10)
INHERITED
quaternion rotation

CODE SAMPLE
block.rotation = quaternion
print(block.rotation) --> quaternion
Methods
applyForce( vector3 force )

CODE SAMPLE
block:applyForce(vector3(10, 10, 10)) --> 
applyForceAtPosition( vector3 force, )

CODE SAMPLE
block:applyForceAtPosition(vector3(10, 10, 10)) --> 
applyImpulse( vector3 force )

CODE SAMPLE
block:applyImpulse(vector3(10, 10, 10)) --> 
applyImpulseAtPosition( vector3 force, )

CODE SAMPLE
block:applyImpulseAtPosition(vector3(10, 10, 10)) --> 
applyTorque( vector3 force )

CODE SAMPLE
block:applyTorque(vector3(10, 10, 10)) --> 
applyTorqueImpulse( vector3 force )

CODE SAMPLE
block:applyTorqueImpulse(vector3(10, 10, 10)) --> 
joint getJoint( string name )

Get a joint from it's name

CODE SAMPLE
block:getJoint("") --> joint
bool playAnimation( string name , bool ?loop , number ?speed )

Returns true if successful

CODE SAMPLE
block:playAnimation("", bool, 1.0) --> bool
bool setAnimationLoop( bool loop )

Returns true if successful. Changes the running animation's loop status

CODE SAMPLE
block:setAnimationLoop(bool) --> bool
bool setAnimationSpeed( number speed )

Returns true if successful. Changes the running animation's speed

CODE SAMPLE
block:setAnimationSpeed(1.0) --> bool
bool stopAnimation( )

Returns true if successful.

CODE SAMPLE
block:stopAnimation() --> bool
INHERITED
destroy( )
CODE SAMPLE
block:destroy() --> 

Destroys this object, further accessing this instance will error

INHERITED
lookAt( vector3 vector )
CODE SAMPLE
block:lookAt(vector3(10, 10, 10)) --> 

Points the sceneObject towards the provided vector

Events
:on("changed", function( string property, variant oldValue, variant newValue ) end)

Fired when a property is changed.

CODE SAMPLE
block:on("changed", function(property, oldValue, newValue)
  print(property) --> ""  print(oldValue) --> variant  print(newValue) --> variant
end)
:on("collisionEnded", function( ) end)

CODE SAMPLE
block:on("collisionEnded", function()

end)
:on("collisionStarted", function( ) end)

CODE SAMPLE
block:on("collisionStarted", function()

end)

Some sections of our docs are maintained on github.