Garry's Mod

Garry's Mod

Improved HUD 2
 This topic has been pinned, so it's probably important
WalkerJetBat  [developer] 9 Jul, 2013 @ 5:19am
API
What's API
API is a function that you can modify Imporved Hud 2 (You can add designs atm via API)

Where do I put API Design file?
Steam\SteamApps\common\GarrysMod\garrysmod\data\improvedhud2\apidesigns

Format
Put .txt file.

API example for Improved Hud 2
local designIndex = "designYourHudName" -- Your design index name for table. (it should be unique) | EX : "designClassic" /* KEEP IN MIND If you want EditEnabled, make sure every draw functions based element.pos.x and element.pos.y If you want CustEnabled, make sure every draw functions based element.backcolor and element.textcolor EXAMPLE draw.RoundedBox(6, element.pos.x, element.pos.y, 404, 60, element.backcolor) -- Background     draw.RoundedBoxEx(6, element.pos.x+2, element.pos.y+2, 400, 20, element.backcolor, true, true, false, false) -- Health     draw.RoundedBoxEx(6, element.pos.x+2, element.pos.y+24, 400, 10, element.backcolor, false, false, true, true) -- Armor draw.SimpleText(LocalPlayer():Armor(), "DarkRPHUD3", element.pos.x+202, element.pos.y+22, element.textcolor, TEXT_ALIGN_CENTER) */ improvedHud.AddDesign(designIndex, {     name = "Classic", -- Name of your HUD.     CustEnabled = false, -- Enable your HUD to change colors of elements. (Background and text)     EditEnabled = false, -- Enable your HUD to change positions of elements.     RemoveOld = false -- Remove old HL2 HUD. }) improvedHud.AddElement(designIndex, { name = "Classic Element 1", -- Name of element. pos = {x = 0, y = 0}, -- Position of element.             posdef = {x = 0, y = 0}, -- Position of element. (Is using for reseting data.)             size = {x = 0, y=0}, -- Size of element. (Is using at edit position panel.)             textcolor = Color(255,255,255), -- Text color of your element. textcolordef = Color(255,255,255), -- Text color of your element. (Is using for reseting data.)             backcolor = Color(0,0,0,200), -- Back color of your element. backcolordef = Color(0,0,0,200), -- Back color of your element. (Is using for reseting data.)             draw = function(element) if IsValid(LocalPlayer()) then -- Your code for element here. -- element.pos.x -> gives you x position. -- element.pos.y -> gives you y position. -- element.textcolor -> gives you text color. -- element.backcolor -> gives you background color. end end }) improvedHud.AddElement(designIndex, { name = "Classic Element 2", pos = {x = 0, y = 0},             posdef = {x = 0, y = 0},             size = {x = 0, y=0},             textcolor = Color(255,255,255),             backcolor = Color(0,0,0,200),             draw = function(element) if IsValid(LocalPlayer()) then -- Your code for element here. -- element.pos.x -> gives you x position. -- element.pos.y -> gives you y position. -- element.textcolor -> gives you text color. -- element.backcolor -> gives you background color. end end })
Last edited by WalkerJetBat; 14 Jul, 2013 @ 7:42am