Code:
	-- Check if we are being run on the server and add this file to the client
if( SERVER )then
	AddCSLuaFile( "textureSheet.lua" );
	
	-- We don't need these functions on the server
	return;
end;
--- TEST CODE
hook.Add("HUDPaint", "testhudpaint", function()
    draw.DrawPartialTexturedRect( 512, 512, 256, 256, 0, 0, CurTime(), CurTime(), "spawnicons/models/alyx_intro.png" );
end);
--- TEST CODE
-- A function to draw a certain part of a texture
function surface.DrawPartialTexturedRect( x, y, w, h, partx, party, partw, parth, texw, texh )
	--[[ 
		Arguments:
		x: Where is it drawn on the x-axis of your screen
		y: Where is it drawn on the y-axis of your screen
		w: How wide must the image be?
		h: How high must the image be?
		partx: Where on the given texture's x-axis can we find the image you want?
		party: Where on the given texture's y-axis can we find the image you want?
		partw: How wide is the partial image in the given texture?
		parth: How high is the partial image in the given texture?
		texw: How wide is the texture?
		texh: How high is the texture?
	]]--
	
	-- Verify that we recieved all arguments
	if not( x && y && w && h && partx && party && partw && parth && texw && texh ) then
		ErrorNoHalt("surface.DrawPartialTexturedRect: Missing argument!");
		
		return;
	end;
	
	-- Get the positions and sizes as percentages / 100
	local percX, percY = partx / texw, party / texh;
	local percW, percH = partw / texw, parth / texh;
	
	-- Process the data
	local vertexData = {
		{
			x = x,
			y = y,
			u = percX,
			v = percY
		},
		{
			x = x + w,
			y = y,
			u = percX + percW,
			v = percY
		},
		{
			x = x + w,
			y = y + h,
			u = percX + percW,
			v = percY + percH
		},
		{
			x = x,
			y = y + h,
			u = percX,
			v = percY + percH
		}
	};
		
	surface.DrawPoly( vertexData );
end;
-- A function to draw a certain part of a texture
function draw.DrawPartialTexturedRect( x, y, w, h, partx, party, partw, parth, texture )
	--[[ 
		Arguments:
		- Also look at the arguments of the surface version of this
		texturename: What is the name of the texture?
	]]--
	
	-- Verify that we recieved all arguments
	if not( x && y && w && h && partx && party && partw && parth && texture ) then
		ErrorNoHalt("draw.DrawPartialTexturedRect: Missing argument!");
		
		return;
	end;
	
	-- Get the positions and sizes as percentages / 100
	local mat = Material( texture, "nocull" );
	local texW = mat:Height()
	local texH = mat:Width()
	local percX, percY = partx / texW, party / texH;
	local percW, percH = partw / texW, parth / texH;
	
	-- Process the data
	local vertexData = {
		{
			x = x,
			y = y,
			u = percX,
			v = percY
		},
		{
			x = x + w,
			y = y,
			u = percX + percW,
			v = percY
		},
		{
			x = x + w,
			y = y + h,
			u = percX + percW,
			v = percY + percH
		},
		{
			x = x,
			y = y + h,
			u = percX,
			v = percY + percH
		}
	};
	
	surface.SetMaterial( mat );
	surface.SetDrawColor( 255, 255, 255, 255 );
	surface.DrawPoly( vertexData );
end;