Skip to main content

WorldText

Accessor to modify World Text from Lua scripts.

info

This module can only be used in Entity scripts.

Properties

canvasSize

Size of the canvas in voxels. This property is read-only.

textColor

Color of the text. This property is read-only.

textAlignment

Alignment of the text. This property is read-only.

fontStyle

Font used for the text. This property is read-only.

fontSize

Size of the text. This property is read-only.

Functions

getText(id)

Get the text that is currently displayed for a target Player.

Parameters

  • id Client ID of the target Player or Players.All.

getVisibility(id)

Returns true if the text object is visible for a target player.

Parameters

  • id Target Player or client ID of the player.

setText(id, text)

Set the text that will be displayed for a target Player.

info

This method can only be used in Entity scripts.

Parameters

  • id Client ID of the target Player or Players.All.
  • text Text value to set.

Example

Set a welcome message for all players.

function onStart()
WorldText.setText(Players.All, 'Welcome to the world!')
end

setVisibility(id, visible)

Set the text's visibility for a target Player.

info

This method can only be used in Entity scripts.

Parameters

  • id Client ID of the target Player or Players.All.
  • visible Boolean for visibility.

Example

Show the WorldText to players when a channel is published.

function onStart()
Channels.subscribe("PlayerEnter", onTriggerEnter)
WorldText.setVisibility(Players.All, false)
end

function onTriggerEnter(id)
WorldText.setVisibility(id, true)
end

setCanvasSize(size)

Sets the size of the canvas that holds text.

info

This method can only be used in Entity scripts.

Parameters

  • size Vector2 of the canvas' size in Voxels.

Example

Set the canvas to occupy a 3x3 voxel space.

function onStart()
WorldText.setCanvasSize(Vector2.new(3, 3))
end

setTextColor(color)

Sets the color of the text displayed.

info

This method can only be used in Entity scripts.

Parameters

  • color New text color.

Example

Set the text to blue.

function onStart()
WorldText.setTextColor(Color.blue)
end

setTextAlignment(textAlignment)

Sets the positioning of the text.

info

This method can only be used in Entity scripts.

Parameters

  • textAlignment TextAlignment value (Use TextAlignment type or numbers 0-8).

Example

Align text to the Top/Left corner.

function onStart()
WorldText.setTextAlignment(TextAlignment.TopLeft)
end

setFontStyle(style)

Sets the font used by text.

info

This method can only be used in Entity scripts.

Parameters

  • style Id number of the font (0-9).

Example

Set Font Style to "Press Start 2P".

function onStart()
WorldText.setFontStyle(8)
end

setFontSize(size)

Sets the size of the text.

info

This method can only be used in Entity scripts.

Parameters

  • size Font size (1-255).

Example

Set Font Size to 200.

function onStart()
WorldText.setFontSize(200)
end