class Label (client-side)
Available since version: 0.3.0
2D text drawing helper for rendering overlay text on screen.
Constructor
Label.new()
Parameters:
No parameters.
Constructor
Label.new(number x, number y, string text)
Parameters:
numberx: Initial X position (virtual units).numbery: Initial Y position (virtual units).stringtext: Initial text content.
Properties
{x, y} position
Represents the label position in virtual screen units.
{x, y} positionPx
Represents the label position in pixel coordinates.
string text
Represents the displayed text.
string font
Represents the font identifier used for rendering.
number width
Represents the rendered text width in virtual screen units.
number height
Represents the rendered text height in virtual screen units.
{r, g, b, a} color
Represents the label's color.
number alpha
Opacity from 0 (transparent) to 255 (opaque).
boolean visible
Represents whether the Label object is rendered.
Methods
setPosition
This function will set the label position in virtual screen units.
void setPosition(number x, number y)
Parameters:
numberx: X position.numbery: Y position.
getPosition
This function will return the label position in virtual screen units.
{x, y} getPosition()
Returns {x, y}:
Table containing x and y numbers.
setPositionPx
This function will set the label position in pixel coordinates.
void setPositionPx(number x, number y)
Parameters:
numberx: X position.numbery: Y position.
getPositionPx
This function will return the label position in pixel coordinates.
{x, y} getPositionPx()
Returns {x, y}:
Table containing x and y numbers.
setText
This function will set the text to render.
void setText(string text)
Parameters:
stringtext: Text to display.
getText
This function will return the current text.
string getText()
Returns string:
Current text.
setFont
This function will set the font used for rendering.
void setFont(string font)
Parameters:
stringfont: Font file name.
getFont
This function will return the current font file name.
string getFont()
Returns string:
Font file name.
getWidth
This function returns the rendered text width in virtual screen units.
number getWidth()
Returns number:
Text width.
getHeight
This function returns the rendered text height in virtual screen units.
number getHeight()
Returns number:
Text height.
setColor
This function will set the text color.
void setColor(number r, number g, number b)
Parameters:
numberr: The red color component in RGB model.numberg: The green color component in RGB model.numberb: The blue color component in RGB model.
getColor
This function will return the current text color.
{r, g, b, a} getColor()
Returns {r, g, b, a}:
Table containing color in RGBA model.
setAlpha
This function will set the text alpha.
void setAlpha(number alpha)
Parameters:
numberalpha: Opacity value (0-255).
getAlpha
This function will return the current alpha
number getAlpha()
Returns number:
Opacity value (0-255).
setVisible
This function will set whether the Label object should render.
void setVisible(boolean visible)
Parameters:
booleanvisible: True to render, false to hide.
getVisible
This function will return whether this Label object is visible.
boolean getVisible()
Returns boolean:
True if visible.
Callbacks
No callbacks.