Class Strings.DisplayString

A string appearing on the screen.

Can be used for subtitles and "2001, somewhere in Egypt"-style messages.

Uses screen-space coordinates, with x values specifying the number of pixels from the left of the window, and y values specifying the number of pixels from the top of the window.

Since different players will have different resolutions, you should work in terms of percentages where possible, and use ScreenToPercent and PercentToScreen when you need to use screen-space coordinates.

Functions

DisplayString(string, position, [scale], [color], [translated], [flags]) Create a DisplayString.
DisplayString:GetColor() Get the display string's color.
DisplayString:SetColor(color) Set the display string's color.
DisplayString:GetKey() Get the string key.
DisplayString:SetKey(key) Set the string key to use.
DisplayString:SetScale(scale) Set the scale of the string.
DisplayString:GetScale() Get the scale of the string.
DisplayString:SetPosition(pos) Set the position of the string.
DisplayString:GetPosition() Get the position of the string.
DisplayString:SetFlags(table) Set the display string's flags.


Functions

DisplayString(string, position, [scale], [color], [translated], [flags])
Create a DisplayString. For use in ShowString and HideString.

Parameters:

  • string string The string to display or key of the translated string.
  • position Vec2 Position of the string in pixel coordinates.
  • scale float Size of the string, relative to the default size. Default: 1.
  • color Color The color of the text. Default: Color(255, 255, 255).
  • translated bool If false or omitted, the input string argument will be displayed. If true, the string argument will be the key of a translated string specified in strings.lua. Default: false.
  • flags DisplayStringOption Flags which affect visual representation of a string, such as shadow or alignment. Optional.

Returns:

    DisplayString A new DisplayString object.
DisplayString:GetColor()
Get the display string's color.

Returns:

    Color Display string's color.
DisplayString:SetColor(color)
Set the display string's color.

Parameters:

  • color Color The new color of the display string.
DisplayString:GetKey()
Get the string key.

Returns:

    string The string key.
DisplayString:SetKey(key)
Set the string key to use.

Parameters:

  • key string The new key for the display string.
DisplayString:SetScale(scale)
Set the scale of the string.

Parameters:

  • scale float New scale of the string relative to the default size.
DisplayString:GetScale()
Get the scale of the string.

Returns:

    float Scale.
DisplayString:SetPosition(pos)
Set the position of the string. Screen-space coordinates are expected.

Parameters:

  • pos Vec2 New position in pixel coordinates.
DisplayString:GetPosition()
Get the position of the string. Screen-space coordinates are returned.

Returns:

    Vec2 pos Position in pixel coordinates.
DisplayString:SetFlags(table)
Set the display string's flags.

Parameters:

  • table table The new table with display flags options.

Usage:

    local varDisplayString = DisplayString('example string', 0, 0, Color(255, 255, 255), false)
    possible values:
    varDisplayString:SetFlags({})
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.CENTER })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW, TEN.Strings.DisplayStringOption.CENTER })
    -- When passing a table to a function, you can omit the parentheses
    varDisplayString:SetFlags{ TEN.Strings.DisplayStringOption.CENTER }
generated by TEN-LDoc (a fork of LDoc 1.4.6)