Simplifies API definition by providing self to all helper methods and allow use of ":" instead of "." in preparation to provide self as the helper methods to all event callbacks.
1.9 KiB
Text Elements
The API for text HUD elements is based off of the main API, however, it makes things even easier when it comes to manipulating the text HUDs. The main reason why this sub-API makes things easier, is that it presents a table for each text element, suited with several functions to manipulate it without requiring that the identification of the element be provided each time you make a change.
list_text
Usage: hudlib.list_text(<player (userdata or string)>)
Lists all text elements attached to a player.
get_text
Usage: hudlib.get_text(<player (userdata or string)>, <hud name (string)>)
Returns a table containing all of the helpers which allow manipulation of the text element. Helpers can be called in this method: hudlib.get_image(...):remove()
(see below for all available helpers).
Helpers:
remove()
- removes the text HUD elementhide()
- hides the textshow()
- shows the text (if it is hidden)set_pos(x, y)
- sets the position of the textset_scale(x, y)
- sets the scale of the textset_text(name)
- changes the textset_alignment(x, y)
- aligns textset_offset(x, y)
- sets positional offset of the textset_colour(colour)
orset_color(color)
- sets the colour of the text (colour
orcolor
is "An integer containing the RGB value of the color used to draw the text. Specify 0xFFFFFF for white text, 0xFF0000 for red, and so on.")
add_text
Usage: hudlib.add_text(<player (userdata or string)>, <hud name (string)>, <definition (table)>)
Adds a text HUD element and returns the helper table described in the get_text
documentation above. Automatically sets the type of the element. The text colour may be specified with either the colour
or color
attributes rather than the number
attribute. See documentation for add
in HUD.md
for information on other custom attributes.