HUD Icons

Okay I’ve been learning lua and I’m having a lot of fun creating HUDs, but I’m trying to make them cleaner by using icons.
I know how to set it as a variable I can use


local moneyicon = Material("icon16/money.png")
local licenseicon = Material("icon/application_side.png")
local wantedicon = Material("icon/exclamation.png")

Like this, but I go to use it and I didn’t think about how positioning would work, I assume it’s x , y
but I wasn’t sure and there was no example on the GMod Wiki.

You’re in the wrong area.

However, when using Material you set it using surface.SetMaterial(). After which, you can use surface.DrawTexturedRect(x,y,w,h) to actually position it and its dimensions.


local moneyicon = Material("icon16/money.png")
local licenseicon = Material("icon/application_side.png")
local wantedicon = Material("icon/exclamation.png")

surface.SetMaterial( Material( wantedicon ) )
surface.SetDrawColor( Color( 255, 255, 255, 255 ) ) -- (r,g,b,Transparency)
surface.DrawTexturedRect( ScrW() - 5 - 16, ScrH() - 5 - 16, 16, 16 )-- (pos x,pos y,x,y)

You should read it
Read it