TextTask
A task for rendering some text from newText
This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.
For this entire page assume:
local myText = models:newText("myCoolTextName")
Text Task
setText()
Aliases: text()
Sets the Text for this task render
setText(text)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | String | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setText("Hi mom!")
getText()
Returns the Text from this task
getText()
Returns:
Type | Description |
---|---|
String | - |
Example:
myText:getText()
setAlignment()
Aliases: alignment()
Sets this Text alignment
Can be either "LEFT", "RIGHT" or "CENTER"
Default "LEFT"
setAlignment(alignment)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alignment | String | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setAlignment("CENTER")
getAlignment()
Returns this Text alignment
Default "LEFT"
getAlignment()
Returns:
Type | Description |
---|---|
String | - |
Example:
myText:getAlignment()
setBackground()
Aliases: background()
Sets if this text should render its background
Defaults to false
setBackground(background)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
background | Boolean | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setBackground(true)
setBackgroundColor()
Aliases: backgroundColor()
Sets the background color of this text
If the alpha value is not given, it will use the vanilla value (as in the accessibility settings)
- Overload 1
- Overload 2
Example:
myText:setBackgroundColor(63 / 255, 255 / 255, 192 / 255, 203 / 255)
getBackgroundColor()
Gets this text's background color
getBackgroundColor()
Returns:
Type | Description |
---|---|
Vector4 | - |
Example:
myText:getBackgroundColor()
setOpacity()
Aliases: opacity()
Sets the opacity of this text
setOpacity(opacity)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
opacity | Number | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setOpacity(0.5)
getOpacity()
Gets the opacity of this text
getOpacity()
Returns:
Type | Description |
---|---|
Number | - |
Example:
myText:getOpacity()
setOutline()
Aliases: outline()
Toggles if the text should render with an outline
The text will always render at full brightness if it is given an outline
Not compatible with "Shadow" and "Emissive" modes
setOutline(outline)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
outline | Boolean | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setOutline(true)
setOutlineColor()
Aliases: outlineColor()
Sets the outline color this Text should render
Only compatible with "Outline" mode
- Overload 1
- Overload 2
Example:
myText:setOutline(true)
myText:setOutlineColor(255 / 255, 192 / 255, 203 / 255)
getOutlineColor()
Gets this tasks text outline color
getOutlineColor()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myText:getOutlineColor()
setSeeThrough()
Aliases: seeThrough()
Sets if this text can be seen behind walls
Defaults to false
setSeeThrough(seeThrough)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seeThrough | Boolean | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setSeeThrough(true)
setShadow()
Aliases: shadow()
Toggles if the Text should render with a drop shadow
Not compatible with "Outline" mode
setShadow(shadow)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shadow | Boolean | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setShadow(true)
setWidth()
Aliases: width()
Sets this text's max width, wrapping the text into multiple lines
A width of 0 or less does not wrap the text
Defaults to 0
setWidth(width)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width | Integer | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setWidth(1)
getWidth()
Gets this text's max width
Defaults to 0
getWidth()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
myText:getWidth()
setWrap()
Aliases: wrap()
Sets if this text should wrap lines
setWrap(wrap)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrap | Boolean | - | - |
Returns:
Type | Description |
---|---|
TextTask | Returns self for chaining |
Example:
myText:setWrap(true)
hasBackground()
Check if this text should render its background
Defaults to false
hasBackground()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myText:hasBackground()
hasOutline()
Checks if this task text has an outline
hasOutline()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myText:hasOutline()
hasShadow()
Checks if this task text has shadow
hasShadow()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myText:hasShadow()
hasWrap()
Check if this text should wrap lines
hasWrap()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myText:hasWrap()
isSeeThrough()
Check if this text can be seen behind walls
Defaults to false
isSeeThrough()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myText:isSeeThrough()
Render Task
setLight()
Aliases: light()
Sets the light override value of this task
Values are given from 0 to 15, indicating the block light and sky light levels you want to use
Passing nil will reset the lighting override for this task
- Overload 1
- Overload 2
setLight(light)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
light | Vector2 | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
setLight(blockLight, skyLight)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blockLight | Integer | - | - |
skyLight | Integer | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
local blockLight = world.getLightLevel(player:getPos())
local skyLight = world.getSkyLightLevel(player:getPos())
myBlock:setLight(blockLight, skyLight)
getLight()
Returns the light override value of this task
getLight()
Returns:
Type | Description |
---|---|
Vector2 | - |
Example:
myBlock:getLight()
setMatrix()
Aliases: matrix()
Sets the given matrix as the position matrix for this render task
The normal matrix is automatically calculated as the inverse transpose of this matrix
Calling this DOES NOT CHANGE the values of position, rot, or scale in the render task
If you call setPos() or a similar function, the effects of setMatrix() will be overwritten
setMatrix(matrix)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix | Matrix4 | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
myBlock:setMatrix(matrices.mat4())
getName()
Get this task's name
getName()
Returns:
Type | Description |
---|---|
String | - |
Example:
myBlock:getName()
getNormalMatrix()
Recalculates the normal matrix for this render task, based on its current position, rotation, scale, and pivot, then returns this matrix
getNormalMatrix()
Returns:
Type | Description |
---|---|
Matrix3 | - |
Example:
myBlock:getNormalMatrix()
getNormalMatrixRaw()
Returns the normal matrix for this render task
The Raw version of the function is different in that it doesn't recalculate the matrix before returning it
getNormalMatrixRaw()
Returns:
Type | Description |
---|---|
Matrix3 | - |
Example:
myBlock:getNormalMatrixRaw()
setOverlay()
Aliases: overlay()
Sets the overlay override value of this task
Values you give are 0 to 15, indicating the white overlay and the damage overlay levels you want to use
Passing nil will reset the overlay override for this task
- Overload 1
- Overload 2
setOverlay(overlay)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
overlay | Vector2 | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
setOverlay(whiteOverlay, hurtOverlay)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
whiteOverlay | Integer | - | - |
hurtOverlay | Integer | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
local hurt = player:getNbt.HurtTime > 0
myBlock:setOverlay(hurt and 0 or nil, 1)
getOverlay()
Returns the overlay override value of this task
getOverlay()
Returns:
Type | Description |
---|---|
Vector2 | - |
Example:
myBlock:getOverlay()
setPos()
Aliases: pos()
Sets the position of the task, relative to its attached part
Uses model coordinates
- Overload 1
- Overload 2
setPos(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | - | - |
y | Number | - | - |
z | Number | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
myBlock:setPos(0, 16, 0)
getPos()
Gets this task position
getPos()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myBlock:getPos()
getPositionMatrix()
Recalculates the matrix for this render task, based on its current position, rotation, scale, and pivot, then returns this matrix
getPositionMatrix()
Returns:
Type | Description |
---|---|
Matrix4 | - |
Example:
myBlock:getPositionMatrix()
getPositionMatrixRaw()
Returns the position matrix for this render task
The Raw version of the function is different in that it doesn't recalculate the matrix before getting it
getPositionMatrixRaw()
Returns:
Type | Description |
---|---|
Matrix4 | - |
Example:
myBlock:getPositionMatrixRaw()
setRot()
Aliases: rot()
Sets the rotation of the task, relative to its attached part
- Overload 1
- Overload 2
setRot(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | - | - |
y | Number | - | - |
z | Number | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
myBlock:setRot(0, 45, 22.5)
getRot()
Gets this task rotation
getRot()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myBlock:getRot()
setScale()
Aliases: scale()
Sets the scale of the task, relative to its attached part
- Overload 1
- Overload 2
setScale(scale)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale | Vector3 | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
setScale(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | - | - |
y | Number | - | - |
z | Number | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
myBlock:setScale(0.4, 0.4, 0.4) -- myBlock:setScale(0.4) also works
getScale()
Gets this task scale
getScale()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myBlock:getScale()
setVisible()
Aliases: visible()
Sets whether or not this task should be rendered
setVisible(visible)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
visible | Boolean | - | - |
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
local myPage = action_wheel.newPage()
myPage:newAction():setOnToggle(function(state)
myBlock:setVisible(state)
end)
isVisible()
Checks if this task is visible
isVisible()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
if myBlock:isVisible() then
-- do something
end
remove()
Removes this render task from the parent model part
remove()
Returns:
Type | Description |
---|---|
RenderTask | - |
Example:
myBlock:remove()