HUD drawing: text, shapes, bars, over the game.
# draw.text (x , y , text , color? , size? , align? )
Parameter Type
xnumber
ynumber
textany
color optional Color default white
size optional number font size (default the UI font)
align optional string "left" (default), "center" or "right" of x
copy draw .text(20 , 20 , "Score: " .. score, "#ffd040" , 26 )
# draw.textSize (text , size? ) → number, number
The size text would take.
Parameter Type
textstring
size optional number
Returns
number width
number height
# draw.fillTriangle (x1 , y1 , x2 , y2 , x3 , y3 , color? )
A filled triangle (arrows, markers).
Parameter Type
x1number
y1number
x2number
y2number
x3number
y3number
color optional Color
# draw.bar (x , y , w , h , fraction , color? , background? )
A filled bar: health bars, progress.
Parameter Type
xnumber
ynumber
wnumber
hnumber
fractionnumber 0-1
color optional Color default green
background optional Color default translucent black
copy draw .bar(sx - 40 , sy, 80 , 8 , c.health / c.maxHealth, "red" )
# draw.screen () → number, number
The screen size in UI units.
Returns
number width
number height
# draw.image (file , x , y , w? , h? , color? ) → boolean
Draws an image: PNG (any common kind, not interlaced) or TGA. Loaded on first use and kept.
Parameter Type
filestring a PNG or TGA file of your mod (path in its folder), or a game file by name
xnumber
ynumber
w optional number width (default: the image's)
h optional number height (default: keeps the shape)
color optional Color tint, and alpha for transparency
Returns
boolean false when the image could not be loaded (logged once)
copy draw .image("hud/compass.png" , e.width - 140 , 20 , 120 )
draw .image("hud/blood.png" , 0 , 0 , e.width, e.height, {1 , 1 , 1 , 0.4 })
# draw.imageSize (file ) → integer?, integer?
An image's size in pixels (nothing when it cannot be loaded).
Returns
integer? width
integer? height