A panel is a custom object made of 2 HUD elements, the title and the background, plus a group of two sub-elements: the text and the images. Picture the background as the container of all the things you want to showcase in your HUD. Those things go in the sub-elements.
To declare a new panel, simply do
local panel = Panel:new(name, {parameters})
The parameters it takes are the following:
player
: required. The player to assign the panel toposition
: the panel position (as in any other HUD)alignment
: sameoffset
: samebg
: the picture to put in the backgroundbg_scale
: its scalingtitle
: the default text. Default is empty (""
)title_size
: (table) as a multiplier, where Y is not considered. Ie. { x = 2}
will double up the font sizetitle_alignment
title_offset
: if offset
is declared already, it'll add/subtract the two valuestitle_color
visible
: (bool) whether the panel is visible right after its creation. Default is true
sub_img_elems
: (table) whatever image to add to the panelsub_txt_elems
: (table) whatever text to add to the panelSub-elements are HUDs added on top of the main container, sharing the same position. This means two things:
panel_lib
automatically overrides the position with the panel's.Have a look at the example file to see a complete panel declaration.
Install it as any other mod ¯\_(ツ)_/¯
new({params})
: creates a new panelshow()
: makes the panel appearhide()
: makes the panel disappear (but it's still assigned to the player)is_visible()
: whether the panel is currently displayedremove()
: deletes itupdate(panel_params, txt_elems, img_elems)
: updates only the mentioned parameters. Beware: panel_params
only supports a few. They are position
, bg
, title
and title_color
.For instance, callingpanel:update(nil, nil, {my_custom_img = {
text = "pic2.png"
})
updates just the text of the sub-element my_custom_img
.
add_sub_elem(type, name, HUD_elem)
: adds a sub-element at runtime. type
must be either text
or image
. HUD_elem
is the table representing the HUDremove_sub_elem(name)
: removes a sub-element at runtimepanel_lib.get_panel(player_name, panel_name)
: obtains the panel associated with a playerSomething's wrong? Feel free to:
I'd really appreciate it :)
I'm Zughy (Marco), a professional Italian pixel artist who fights for FOSS and digital ethics. If this library spared you a lot of time and you want to support me somehow, please consider donating on LiberaPay. Also, this project wouldn't have been possible if it hadn't been for some friends who helped me testing through: SonoMichele
, _Zaizen_
and Xx_Crazyminer_xX