Nook Retro HUD

Hey! My name is Nookyava and I just recently started coding in the past three weeks. I’ve worked on small things and odd jobs, but I coded a HUD that works both for TTT and Sandbox. I was hoping to post it here and get some critiques or ideas of what I can do better. I’m also going to post the code so you can see how horribly optimized and setup it is.

[video]http://youtube.com/watch?v=6f5DywNEKFc[/video]

Screenshot showing TTT version of the HUD.

http://cloud-3.steampowered.com/ugc/920146124959934177/371460ABBAF9D4991C26E9E5908B97B214FCD852/637x358.resizedimage[/t]

Screenshot showing the gamemode selection part of the HUD, as well as Sandbox.

[t]http://cloud-4.steampowered.com/ugc/920146125007828174/18D30E1EA19AAF04E8B3F50FD739B2868D706AFC/637x358.resizedimage

cl_hud.lua


---------------------------------
----- This is the Menu part -----
---------------------------------

function TestVGUI( )
	if LocalPlayer():IsSuperAdmin() then
		local NookMenu = vgui.Create( "DFrame" )
		NookMenu:SetSize( 500, 75 )
		NookMenu:SetPos( ScrW()/2 - 200, ScrH()/2 - 100 )
		NookMenu:ShowCloseButton( true )
		NookMenu:SetVisible( true )
		NookMenu:MakePopup( )
		NookMenu:SetTitle( "Nookyava's Retro Hud Settings" )
	
		local Sandbox = vgui.Create( "Button", NookMenu )
		Sandbox:SetText( "Sandbox" )
		Sandbox:SetPos( 25, 35 )
		Sandbox:SetWide( 100 )
		function Sandbox:DoClick( )
			self:SetText( "Sandbox Mode Set" )
			timer.Simple( 0.5, function()
				self:SetText( "Sandbox" )
			end)
			
			net.Start( "Gamemode Setting" )
			net.WriteDouble( 0 )
			net.SendToServer()
		end
		
		local DarkRP = vgui.Create( "Button", NookMenu )
		DarkRP:SetText( "DarkRP" )
		DarkRP:SetPos( 200, 35 )
		DarkRP:SetWide( 100 )
		function DarkRP:DoClick( )
			--self:SetText( "DarkRP Mode Set" )
			--timer.Simple( 3, function()
			--	self:SetText( "DarkRP" )
			--end)
			LocalPlayer():ChatPrint("DarkRP Mode has not been created yet, thank you for your interest though!")
		end
		
		local TTT = vgui.Create( "Button", NookMenu )
		TTT:SetText( "TTT" )
		TTT:SetPos( 375, 35 )
		TTT:SetWide( 100 )
		function TTT:DoClick( )
			self:SetText( "TTT Mode Set" )
			timer.Simple( 0.5, function()
				self:SetText( "TTT" )
			end)
			
			net.Start( "Gamemode Setting" )
			net.WriteDouble( 1 )
			net.SendToServer()
		end
	else return end 
end
concommand.Add("nookhud", TestVGUI)

----------------------------------------------
--   This is just setting up the materials. --
--  Thank you [find me] for the suggestion! --
----------------------------------------------

HeartMat = {}

HeartMat[10] = Material("nook/heart_hud/horizontal_heart/full.png")
HeartMat[9] = Material("nook/heart_hud/horizontal_heart/hurt_once.png")
HeartMat[8] = Material("nook/heart_hud/horizontal_heart/hurt_twice.png")
HeartMat[7] = Material("nook/heart_hud/horizontal_heart/hurt_thrice.png")
HeartMat[6] = Material("nook/heart_hud/horizontal_heart/hurt_four.png")
HeartMat[5] = Material("nook/heart_hud/horizontal_heart/hurt_five.png")
HeartMat[4] = Material("nook/heart_hud/horizontal_heart/hurt_six.png")
HeartMat[3] = Material("nook/heart_hud/horizontal_heart/hurt_seven.png")
HeartMat[2] = Material("nook/heart_hud/horizontal_heart/hurt_eight.png")
HeartMat[1] = Material("nook/heart_hud/horizontal_heart/hurt_nine.png")
HeartMat[0] = Material("nook/heart_hud/horizontal_heart/hurt_ten.png")

ArmorMat = {}

ArmorMat[10] = Material("nook/heart_hud/shield/full.png")
ArmorMat[9] = Material("nook/heart_hud/shield/hurt_once.png")
ArmorMat[8] = Material("nook/heart_hud/shield/hurt_twice.png")
ArmorMat[7] = Material("nook/heart_hud/shield/hurt_thrice.png")
ArmorMat[6] = Material("nook/heart_hud/shield/hurt_four.png")
ArmorMat[5] = Material("nook/heart_hud/shield/hurt_five.png")
ArmorMat[4] = Material("nook/heart_hud/shield/hurt_six.png")
ArmorMat[3] = Material("nook/heart_hud/shield/hurt_seven.png")
ArmorMat[2] = Material("nook/heart_hud/shield/hurt_eight.png")
ArmorMat[1] = Material("nook/heart_hud/shield/hurt_nine.png")
ArmorMat[0] = Material("nook/heart_hud/shield/hurt_ten.png")


local PistolAmmo = Material("nook/heart_hud/ammo/pistol.png")
local ShotgunAmmo = Material("nook/heart_hud/ammo/shotgun.png")
local SMGAmmo =  Material("nook/heart_hud/ammo/smg.png")
local RifleAmmo =  Material("nook/heart_hud/ammo/rifle.png")

-------------------------------
-- This is creating the text --
-------------------------------


surface.CreateFont( "HeartText", {
	font = "MenuLarge",
	size = 25,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = false,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = true,
	additive = false,
	outline = true
} )

surface.CreateFont( "WeaponText", { 
	font = "TitleFont",
	size = 25,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = false,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = true,
	additive = false,
	outline = true
} )

surface.CreateFont( "RoleText", {
	font = "TargetID",
	size = 25,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = false,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = true,
	additive = false,
	outline = false
} )

surface.CreateFont( "ClockText", {
	font = "HUDNumber",
	size = 35,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = false,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = true,
	additive = false,
	outline = true
} )

------------------------------
-- This is creating our HUD --
------------------------------

local function HealthHud()
	if !LocalPlayer():Alive() then return end
	if LocalPlayer():Team() == TEAM_SPEC then return end
	local health = LocalPlayer():Health()
	local Health_Increment = math.Round( health/10 )
	local Width = 203 
	local Height = 203
	
	surface.SetDrawColor(255,255,255,255)	
	surface.SetMaterial( HeartMat[Health_Increment] )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
	
end 
hook.Add("HUDPaint", "HeartHUD", HealthHud) 

local function ArmorHud()
	if !LocalPlayer():Alive() then return end
	if LocalPlayer():Team() == TEAM_SPEC then return end
	local armor = LocalPlayer():Armor()
	local Armor_Increment = math.Round( armor/10 )
	local Width = 110 
	local Height = 120 
	
	surface.SetDrawColor(255,255,255,255)
	if GetConVar("NookHUD_Gamemode"):GetInt() == 0 then
		surface.SetMaterial( ArmorMat[Armor_Increment] )
		surface.DrawTexturedRect(200, ScrH() - Height - 15, Width, Height )
		draw.DrawText( armor, "HeartText", 255, ScrH() - Height + 27, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
	elseif GetConVar("NookHUD_Gamemode"):GetInt() == 1 then
		if LocalPlayer():HasEquipmentItem(EQUIP_ARMOR) then
			surface.SetMaterial( ArmorMat[10] )
			surface.DrawTexturedRect(200, ScrH() - Height - 25, Width, Height )
		elseif !LocalPlayer():HasEquipmentItem(EQUIP_ARMOR) then
			surface.SetDrawColor(255,255,255,55)	
			surface.SetMaterial( ArmorMat[0] )
			surface.DrawTexturedRect(200, ScrH() - Height - 25, Width, Height )
		end
	end
end
hook.Add("HUDPaint", "ShieldHUD", ArmorHud) 

local function AmmoHud()
	if !LocalPlayer():Alive() then return end
	if GetConVar("NookHUD_Gamemode"):GetInt() == 1 then -- This is the TTT config at the top.
		if !LocalPlayer():IsTerror() then return end
	end
	weapon = LocalPlayer():GetActiveWeapon()
	ammo = IsValid( weapon ) and LocalPlayer():GetActiveWeapon():Clip1()
	ammo2 = IsValid( weapon ) and LocalPlayer():GetAmmoCount(LocalPlayer():GetActive  Weapon():GetPrimaryAmmoType())
	ammo3 = IsValid( weapon ) and LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType  ()
	--print(ammo3)
	if ammo == nil then return end -- These are to prevent a small error that will appear on death in TTT. :IsAlive() does not stop this from occuring.
	if ammo2 == nil then return end
	if ammo3 == nil then return end
	local Width = 87
	local Height = 93
	
	if ammo3 == 3 then
		Ammo = PistolAmmo
		WidthAmmo = 96.5
		Width1 = 1195
		Height1 = 75
		HeightAmmo = 68 
	elseif ammo3 == 7 then
		Ammo = ShotgunAmmo
		WidthAmmo = 87 
		Width1 = 1200
		Height1 = 93
		HeightAmmo = 93 
	elseif ammo3 == 4 || ammo3 == 20 then 
		Ammo = SMGAmmo
		WidthAmmo = 89 
		Width1 = 1200
		Height1 = 75
		HeightAmmo = 62 
	elseif ammo3 == 12 || ammo3 == 5 then
		Ammo = RifleAmmo
		WidthAmmo = 89 
		Width1 = 1200
		Height1 = 68
		HeightAmmo = 62
	else
		Ammo = PistolAmmo
		WidthAmmo = 96.5
		Width1 = 1195
		Height1 = 75
		HeightAmmo = 68 
	end
	
	if IsValid( weapon ) and ammo >= 0 then
		surface.SetDrawColor(255,255,255,255)
		surface.SetMaterial( Ammo )
		if IsValid( weapon ) and ammo2 >= 100 then
			draw.DrawText( ammo, "HeartText", 1205, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			draw.DrawText( "x ", "HeartText", 1300, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			draw.DrawText( ammo2, "HeartText", 1340, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			surface.DrawTexturedRect(Width1, ScrH() - Height1 - 15, WidthAmmo, HeightAmmo )
		elseif IsValid( weapon ) and ammo2 < 100 then
			draw.DrawText( ammo, "HeartText", 1205, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			draw.DrawText( "x ", "HeartText", 1300, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			draw.DrawText( ammo2, "HeartText", 1320, ScrH() - Height + 30, Color( 255, 255, 255, 255), TEXT_ALIGN_RIGHT)
			surface.DrawTexturedRect(Width1, ScrH() - Height1 - 15, WidthAmmo, HeightAmmo )
		end
	end
end
hook.Add("HUDPaint", "AmmoHUD", AmmoHud) 

local function TroubleInTerroristTownDraw() -- This is a function to just draw if TTT is one, so then we draw the clock and such without having errors in any other gamemode.
	local Width = 203 
	local Height = 203 
	if GetConVar("NookHUD_Gamemode"):GetInt() == 1 then
		surface.SetDrawColor(255,255,255,255)
		if LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPEC then
			if LocalPlayer():GetTraitor() then
				--draw.DrawText( "Role:", "RoleText", 75, ScrH() - Height + 35, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
				draw.DrawText( "Traitor", "RoleText", 105, ScrH() - Height + 35, Color( 255, 0, 0, 255), TEXT_ALIGN_CENTER)
			elseif LocalPlayer():GetDetective() then
				--draw.DrawText( "Role:", "RoleText", 70, ScrH() - Height + 35, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
				draw.DrawText( "Detective", "RoleText", 105, ScrH() - Height + 35, Color( 0, 0, 255, 255), TEXT_ALIGN_CENTER)
			elseif LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPEC then
				--draw.DrawText( "Role:", "RoleText", 70, ScrH() - Height + 35, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
				draw.DrawText( "Innocent", "RoleText", 103, ScrH() - Height + 35, Color( 0, 255, 0, 255), TEXT_ALIGN_CENTER)
			end
		end
		
		surface.SetFont("ClockText")
		surface.SetTextColor(255, 255, 255, 255)
		
		draw.DrawText(":", "ClockText", ScrW() / 2 + 11, ScrH() - 61, Color(255,255,255,255))
		
		local round_state = GAMEMODE.round_state
		local is_haste = HasteMode() and round_state == ROUND_ACTIVE
		local endtime = GetGlobalFloat("ttt_round_end", 0) - CurTime()
		local text
		
		if is_haste then
			local hastetime = GetGlobalFloat("ttt_haste_end", 0) - CurTime()
			if hastetime < 0 then
				if (!is_traitor && LocalPlayer():Team() != TEAM_SPEC) or (math.ceil(CurTime()) % 7 <= 2) then
					surface.SetTextColor(120, 126, 122, 255)
					surface.SetTextPos(ScrW() / 2 - 26, ScrH() - 100)
					surface.DrawText('OVERTIME')
			
					surface.SetTextColor(255, 255, 255, 255)
					text = '00:00'
				else
					text  = string.ToMinutesSeconds(math.max(0, endtime), "%02i:%02i")
					surface.SetTextColor(255, 0, 0, 255)
				end
			else
			
			local t = hastetime
			
			if is_traitor and math.ceil(CurTime()) % 6 < 2 then
				surface.SetTextColor(255, 0, 0, 255)
				t = endtime
			end
			
			text = string.ToMinutesSeconds(math.max(0, t), "%02i:%02i")
		end
		
		else
			text = string.ToMinutesSeconds(math.max(0, endtime), "%02i:%02i")
		end
		
		// Tile 1
		local Tile1 = string.Left(text, 2)
		local Tile1a = string.Right(Tile1, 1)
		surface.SetTextPos(ScrW() / 2 - 9, ScrH() - 59) 
		surface.DrawText(Tile1a)

		// Tile 2
		local Tile2 = string.Left(text, 4)
		local Tile2a = string.Right(Tile2, 1)
		surface.SetTextPos(ScrW() / 2 + 26, ScrH() - 59) 
		surface.DrawText(Tile2a)
	
		// Tile 3
		local Tile3 = string.Right(text, 1)
		surface.SetTextPos(ScrW() / 2 + 50, ScrH() - 59) 
		surface.DrawText(Tile3)
		end
end
hook.Add("HUDPaint", "TTTHud", TroubleInTerroristTownDraw) 

function hidehud(name) -- This hides what we don't want in sandbox.
	for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"})do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "HideWhatWeDontWant", hidehud)


sv_hud.lua


util.AddNetworkString( "Gamemode Setting" )

CreateConVar( "NookHUD_Gamemode", 1,  {FCVAR_ARCHIVE, FCVAR_REPLICATED} )

net.Receive( "Gamemode Setting", function()
	NookHudSetting = net.ReadDouble()
	--print(NookHud)
	if NookHudSetting == 0 then
		game.ConsoleCommand( "NookHUD_Gamemode 0
" )
	elseif NookHudSetting == 1 then
		game.ConsoleCommand( "NookHUD_Gamemode 1
" )
	end
end)

if SERVER then
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/full.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_eight.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_five.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_four.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_nine.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_once.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_seven.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_six.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_ten.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_thrice.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/horizontal_heart/hurt_twice.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/full.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_eight.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_five.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_four.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_nine.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_once.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_seven.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_six.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_ten.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_thrice.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/shield/hurt_twice.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/ammo/pistol.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/ammo/rifle.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/ammo/shotgun.png")
	resource.AddFile("Nook_Hud/materials/nook/heart_hud/ammo/smg.png")
end

If you have any suggestions, please, let me know. I want to improve as much as I can. I understand it’s not the best HUD, and the coding is probably raw, but I’m proud of it and want to make it better.

Links:

http://steamcommunity.com/sharedfiles/filedetails/?id=172249151 – Workshop

https://www.dropbox.com/s/etwq09hkcw1x4x4/Nook%20Hud.rar – Download

8/30/2013 Update:

[*] Took Find Me’s suggestion towards putting it in tables, and it definitely cleaned up my code. Currently I am looking into using rectangles and the SetScissorRect in order to just use a rectangle to draw the inside of the heart (requiring only one download for heart, and one for shield, and the four for ammo) I also made the timer on the text to 0.5, to reduce chance of an error. Finally, I also increased the shield size to roughly the same as the heart. Thank you all for the positive feedback, and hopefully I can continue to do well!

Love it

I think it is very ugly

Could you please tell me what about it is ugly, and what could be improved then please?

Sweet :3… It Looks really cool :D.

I tried it out on my TTT server, and i think i installed it correcly but im getting this error:


[ERROR] gamemodes/terrortown/gamemode/cl_hud.lua:291: function arguments expecte
d near 'Weapon'
  1. unknown - gamemodes/terrortown/gamemode/cl_hud.lua:0

But maybe I installed it incorrecly? So maybe could you give a guide on how you install?

Thanks and nice work :stuck_out_tongue:

Really love the health and armor. As for the ammo and time displays, they’re a bit bland.

Yea, I was trying to work in an 8-bit version but no luck so far.

I probably should have mentioned it’s an addon, so running it in as the actual HUD will cause errors. Revert the cl_hud.lua to the original of TTT, and put these in an addon. I’ll put in a download of the addon as well as a link to the workshop.

Why do you have pictures for everything?
You could simply draw it and it would reduce the files to download…

I personally hate this minecrafty-pixel thing - but it is nicely coded.

I use the pictures since I didn’t exactly see a way to have the heart filled with the box without having to put multiple boxes for one part. In the future I might fix that though.

Where’s the problem with multiple boxes?

There isn’t an issue I suppose, looking at it now. I’ll look into it.

Nope there is no issue :slight_smile:

Thank you for the suggestion. I’ll post an update soon with less downloads with the heart being drawn primarily by boxes.

Idea, focus on tables more as they can do wonders for your “horribly optimized code”. By the way it’s not horrible, just basic.

Here’s an example of a really useful table use in your code.
[lua]
local Heart100 = Material(“nook/heart_hud/horizontal_heart/full.png”)
local Heart90 = Material(“nook/heart_hud/horizontal_heart/hurt_once.png”)
local Heart80 = Material(“nook/heart_hud/horizontal_heart/hurt_twice.png”)
local Heart70 = Material(“nook/heart_hud/horizontal_heart/hurt_thrice.png”)
local Heart60 = Material(“nook/heart_hud/horizontal_heart/hurt_four.png”)
local Heart50 = Material(“nook/heart_hud/horizontal_heart/hurt_five.png”)
local Heart40 = Material(“nook/heart_hud/horizontal_heart/hurt_six.png”)
local Heart30 = Material(“nook/heart_hud/horizontal_heart/hurt_seven.png”)
local Heart20 = Material(“nook/heart_hud/horizontal_heart/hurt_eight.png”)
local Heart10 = Material(“nook/heart_hud/horizontal_heart/hurt_nine.png”)
local Heart0 = Material(“nook/heart_hud/horizontal_heart/hurt_ten.png”)


if health &gt;= 100 then
	surface.SetMaterial( Heart100 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 90 then
	surface.SetMaterial( Heart90 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 80 then
	surface.SetMaterial( Heart80 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 70 then
	surface.SetMaterial( Heart70 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 60 then
	surface.SetMaterial( Heart60 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 50 then
	surface.SetMaterial( Heart50 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 40 then
	surface.SetMaterial( Heart40 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 30 then
	surface.SetMaterial( Heart30 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 20 then
	surface.SetMaterial( Heart20 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health &gt;= 10 || health &gt;= 1 then
	surface.SetMaterial( Heart10 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
	draw.DrawText( health, "HeartText", 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
elseif health == 0 then
	surface.SetMaterial( Heart0 )
	surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
end

[/lua]
TO THIS
[lua]
Materials = {}

Materials[10] = Material(“nook/heart_hud/horizontal_heart/full.png”)
Materials[9] = Material(“nook/heart_hud/horizontal_heart/hurt_once.png”)
Materials[8] = Material(“nook/heart_hud/horizontal_heart/hurt_twice.png”)
Materials[7] = Material(“nook/heart_hud/horizontal_heart/hurt_thrice.png”)
Materials[6] = Material(“nook/heart_hud/horizontal_heart/hurt_four.png”)
Materials[5] = Material(“nook/heart_hud/horizontal_heart/hurt_five.png”)
Materials[4] = Material(“nook/heart_hud/horizontal_heart/hurt_six.png”)
Materials[3] = Material(“nook/heart_hud/horizontal_heart/hurt_seven.png”)
Materials[2] = Material(“nook/heart_hud/horizontal_heart/hurt_eight.png”)
Materials[1] = Material(“nook/heart_hud/horizontal_heart/hurt_nine.png”)
Materials[0] = Material(“nook/heart_hud/horizontal_heart/hurt_ten.png”)

local Health_Increment = math.Round( health/10 )

surface.SetMaterial( Materials[Health_Increment] )
surface.DrawTexturedRect(0, ScrH() - Height + 25, Width, Height )
draw.DrawText( health, “HeartText”, 102, ScrH() - Height + 110, Color( 255, 255, 255, 255), TEXT_ALIGN_CENTER)
[/lua]

Yeah I was going to say the code is very ugly. You should have used render.SetScrissorRect for the health code.

Minecraft wasn’t the first game to utilize pixels. Infiniminer is a thing, you know.

I don’t think I have played a game without pixels before and the thing is that minecraft
popularized voxel based games or is at least the most popular voxel based game today.
So making a reference to minecraft would allow for more people to understand what he
was saying than if he instead said “this Infiniminer-pixel thing”.

Anyways, I like the HUD and thank you for releasing it.

It’s a nice HUD, but my previous comment on it I still think you should do.

(It was to make the shield the same size as the heart)

Thank you, I’ll make sure to try and compact the code more, this will help a lot. Hopefully it will be using less downloads anyway.

I’ll take that into effect when coding it, thank you.

Updated cl_hud.lua to Find Me’s suggestions. Thanks a lot!

Also made the shield the same size as the heart.