{"id":13621794,"url":"https://github.com/DyaMetR/holohud","last_synced_at":"2025-04-15T01:34:07.214Z","repository":{"id":43149543,"uuid":"179951161","full_name":"DyaMetR/holohud","owner":"DyaMetR","description":"Customizable holographic themed heads up display (HUD) for Garry's Mod.","archived":false,"fork":false,"pushed_at":"2024-08-21T10:39:16.000Z","size":698,"stargazers_count":13,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T08:42:32.191Z","etag":null,"topics":["addon","gmod","lua"],"latest_commit_sha":null,"homepage":"https://steamcommunity.com/sharedfiles/filedetails/?id=1705992410","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DyaMetR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-07T10:40:37.000Z","updated_at":"2024-10-01T09:43:27.000Z","dependencies_parsed_at":"2024-01-14T08:07:02.431Z","dependency_job_id":null,"html_url":"https://github.com/DyaMetR/holohud","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DyaMetR%2Fholohud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DyaMetR%2Fholohud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DyaMetR%2Fholohud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DyaMetR%2Fholohud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DyaMetR","download_url":"https://codeload.github.com/DyaMetR/holohud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989518,"owners_count":21194606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addon","gmod","lua"],"created_at":"2024-08-01T21:01:10.636Z","updated_at":"2025-04-15T01:34:07.203Z","avatar_url":"https://github.com/DyaMetR.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# H0L-D4: Holographic Heads Up Display\n\n![](https://img.shields.io/github/v/release/DyaMetR/holohud)\n![](https://img.shields.io/steam/views/1705992410)\n![](https://img.shields.io/steam/downloads/1705992410)\n![](https://img.shields.io/steam/favorites/1705992410)\n![](https://img.shields.io/github/issues/DyaMetR/holohud)\n![](https://img.shields.io/github/license/DyaMetR/holohud)\n\n\u003e This repository has been archived in favour of an [updated version](https://github.com/DyaMetR/holohud2).\n\nCustomizable holographic themed heads up display (HUD) for Garry's Mod.\n\n## Features\n\n+ HUD swaying with camera movement\n+ Chromatic aberration\n+ Health indicator\n+ Armour indicator\n+ Ammunition indicator\n+ Weapon selector\n+ Ping meter\n+ Player counter\n+ Prop counter\n+ Killfeed\n+ Speed-o-meter\n+ Environmental hazards indicator\n+ Clock\n+ Compass\n+ Damage indicator\n+ Pickup history\n+ Entity information\n+ Target ID\n+ Welcome screen\n\n## Customization includes\n\n+ Each elements has their own array of options\n+ Font family and offsets customization\n+ Blur intensity and opacity\n+ Background opacity\n+ Swaying\n\n## Credits\n\n+ *DyaMetR*\n   + Design\n   + Code\n   + Sprites\n+ *Matsilagi*\n   + Testing\n   + Occasional development support\n+ *code_gs*\n   + [Weapon selector skeleton](https://github.com/Kefta/Weapon-Switcher-Skeleton)\n\n## Adding custom content\n\n### Setup your configuration folder\n\nTo ensure that your configuration _loads correctly_, you'll have to make a **folder** inside your **addons** folder with a specific structure: `%YOUR_CONFIG_ADDON_FOLDER%/lua/autorun/holohud/add-ons`.\n\nOnce you created your folder you'll be able to add as many `.lua` files as you wish and the HUD will load them all. Try to use **unique file names** in order to avoid conflicts with other addons.\n\n### Before you start writing code\n\nAll of the custom files are loaded **shared**wise, meaning that it will work in both clientside and serverside, so I'd like to remind using `if CLIENT` and `if SERVER` respectively.\n\n### Utilizing the API\n\nH0L-D4 offers an ample API, but I will only list the most important functions, which are those in charge of adding elements and forcing settings.\n\n#### Add element override\n\n`HOLOHUD.GAMEMODE:AddElementOverride( gamemode, elements )`\n\u003e **CLIENT**\n\n\u003e Makes an element or group of elements only work for a certain gamemode or group of gamemodes\n\n\u003e **@param** {string|table} gamemode or gamemodes\n\n\u003e **@param** {string|table} element or elements\n\nExamples:\n\n```lua\n--[[\n  Make that the hypothetical elements 'money', 'job' and 'lockdown'\n  only are available when the server is running DarkRP\n]]\nHOLOHUD.GAMEMODE:AddElementOverride( 'darkrp', { 'money', 'job', 'lockdown' } )\n\n--[[\n  Make that the hypothetical elements 'ttt_role' and 'ttt_clock'\n  only are available when the server is running Trouble in Terrorist Town\n]]\nHOLOHUD.GAMEMODE:AddElementOverride( 'terrortown', { 'ttt_role', 'ttt_clock' } )\n\n--[[\n  Make that the element 'prop_count' only works on Sandbox and DarkRP\n]]\nHOLOHUD.GAMEMODE:AddElementOverride( { 'sandbox', 'darkrp' }, 'prop_count' )\n\n```\n\n#### Set element override\n\n`HOLOHUD.GAMEMODE:SetElementOverride( gamemode, elements, whitelist )`\n\u003e **CLIENT**\n\n\u003e Blacklists elements on certain gamemodes. The 'whitelist' parameter, if true, will make the provided element/s from the 'elements' parameter the only ones that will be shown when playing on the provided gamemode/s via the 'gamemode' parameter.\n\n\u003e **@param** {string|table} gamemode or gamemodes\n\n\u003e **@param** {string|table} element or elements\n\nExamples:\n\n```lua\n--[[\n  Disable the 'target_id' element when playing DarkRP\n]]\nHOLOHUD.GAMEMODE:SetElementOverride( 'darkrp', 'target_id' )\n\n--[[\n  Only the elements 'health', 'ammunition', 'ttt_role' and 'ttt_clock'\n  will be the ones enabled when playing Trouble in Terrorist Town, any\n  other elements will be unavailable\n]]\nHOLOHUD.GAMEMODE:SetElementOverride( 'terrortown', { 'health', 'ammunition', 'ttt_role', 'ttt_clock' }, true )\n\n--[[\n  Disable the 'killfeed' element from DarkRP and Trouble in Terrorist Town\n]]\nHOLOHUD.GAMEMODE:SetElementOverride( { 'darkrp', 'terrortown' }, 'target_id' )\n```\n\n### Add element configuration override\n\n`HOLOHUD.GAMEMODE:AddConfigOverride( gamemode, element, config, force_default )`\n\u003e **CLIENT**\n\n\u003e Forces configuration parameters' values on a certain element for a certain gamemode\n\n\u003e **@param** {string} gamemode\n\n\u003e **@param** {string} element\n\n\u003e **@param** {table} a list with the overrided parameters and their new values\n\n\u003e **@param** {boolean} if true, it will force the default configuration on those parameters that were not included on the 'config' table. otherwise, it will load the user configuration.\n\nExamples:\n\n```lua\n--[[\n  Force heartrate monitor with kevlar icon and minimalistic ammunition\n  indicator on DarkRP\n]]\nHOLOHUD.GAMEMODE:AddConfigOverride( 'darkrp', 'health', { mode = 3 } )\nHOLOHUD.GAMEMODE:AddConfigOverride( 'darkrp', 'ammunition', { mode = 2 } )\n\n--[[\n  Force compact mode and always display while ignoring user configuration\n  on the ammunition indicator when playing Trouble in Terrorist Town\n]]\nHOLOHUD.GAMEMODE:AddConfigOverride( 'terrortown', 'ammunition', { mode = 3 }, true )\n\n```\n\n#### Cheat sheet for element's modes\n\n##### Health\n\n```\n1 = Default\n2 = Heartbeat with armour bar\n3 = Heartbeat with kevlar icon\n4 = Classic\n```\n\n##### Ammunition\n\n```\n1 = Default\n2 = Minimalist\n3 = Compact\n```\n\n##### Clock\n\n```\n1 = Simple\n2 = Digital\n3 = Simple with date\n```\n\n##### Speed-o-meter (units for both in foot and in vehicle)\n\n```\n1 = km/h\n2 = mph\n3 = ups\n```\n\n##### Auxiliary power (for both the aux. power and the ep2 flashlight)\n\n```\n1 = Default\n2 = Icon with background\n3 = Icon only\n```\n\n### Setup panel\n\n\"Panels\" are the rectangles used as background to draw stuff. They can be opened or closed, which will play an animation in the process.\n\nThey're independent of 'HUD elements' but are usually declared and used alongside them.\n\n`HOLOHUD:AddFlashPanel( panel )`\n\n\u003e **CLIENT**\n\n\u003e Adds a panel to the display list\n\n\u003e **@param** {string} flash panel name\n\nExample:\n```lua\n--[[\n  Add a panel named 'out_of_ammo'\n]]\nHOLOHUD:AddFlashPanel( 'out_of_ammo' )\n```\n\n### Open/close a panel\n\n`HOLOHUD:SetPanelActive( panel, active, force )`\n\n\u003e **CLIENT**\n\n\u003e Sets whether a panel should be displayed (triggers the animations)\n\n\u003e **@param** {string} panel name\n\n\u003e **@param** {boolean} whether the panel should be displayed or not\n\n\u003e **@param** {boolean|nil} whether it should override user configuration (should HUD hide on death and should HUD draw without the Suit)\n\nExample:\n```lua\n--[[\n  Trigger the panel 'out_of_ammo' when you're out of ammo\n]]\nlocal function TriggerOutOfAmmoPanel()\n\n  local weapon = LocalPlayer():GetActiveWeapon()\n\n  if not IsValid( weapon ) or ( weapon:GetPrimaryAmmoType() \u003c= 0 and weapon:GetSecondaryAmmoType() \u003c= 0 ) then return end\n\n  local clip, reserve, alt = weapon:Clip1(), LocalPlayer():GetAmmoCount( weapon:GetPrimaryAmmoType() ), LocalPlayer():GetAmmoCount( weapon:GetSecondaryAmmoType() )\n\n  HOLOHUD:SetPanelActive( 'out_of_ammo', clip \u003c= 0 and reserve \u003c= 0 and alt \u003c= 0 )\n\nend\n```\n\n### Draw panel with contents\n\n`HOLOHUD:DrawFragmentAlignSimple( x, y, w, h, func, flash, align, ... )`\n\u003e **CLIENT**\n\n\u003e Draws an animated panel, with contents, that can be toggled\n\n\u003e **@param** {number} x position\n\n\u003e **@param** {number} y position\n\n\u003e **@param** {number} width\n\n\u003e **@param** {number} height\n\n\u003e **@param** {function} contents draw function\n\nUses the arguments: `x`, `y`, `width`, `height`\n\n\u003e **@param** {string} panel ID\n\n\u003e **@param** {TEXT_ALIGN_} flash effect alignment\n\n\u003e **@param** {varargs} additional parameters sent to the contents drawing function\n\nExample:\n```lua\nlocal WIDTH, HEIGHT = 200, 50\nlocal PANEL = 'out_of_ammo'\nlocal LOCALE = 'OUT OF AMMO'\nlocal FONT, COLOUR = 'holohud_med_sm', Color( 255, 0, 0 )\n\n--[[\n  Draw contents\n]]\nlocal function DrawPanel( y )\n\n  HOLOHUD:DrawFragmentAlignSimple( ( ScrW() * .5 ) - ( WIDTH * .5 ), ScrH() * y, WIDTH, HEIGHT, function( x, y, w, h )\n\n    HOLOHUD:DrawText( x + ( w * .5), y + ( h * .5 ), LOCALE, FONT, COLOUR, HOLOHUD:GetHighlight(PANEL), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )\n\n  end, PANEL, TEXT_ALIGN_TOP )\n\nend\n```\n\n### Draw panel with contents (with additional parameters)\n\n`HOLOHUD:DrawFragmentAlign( x, y, w, h, func, flash, align, colour, alpha, blurQuality, ... )`\n\u003e **CLIENT**\n\n\u003e Draws an animated panel, with contents, that can be toggled, with additional parameters\n\n\u003e **@param** {number} x position\n\n\u003e **@param** {number} y position\n\n\u003e **@param** {number} width\n\n\u003e **@param** {number} height\n\n\u003e **@param** {function} contents draw function\n\nUses the arguments: `x`, `y`, `width`, `height`\n\n\u003e **@param** {string} panel ID\n\n\u003e **@param** {TEXT_ALIGN_} flash effect alignment\n\n\u003e **@param** {Color} background colour\n\n\u003e **@param** {number} opacity\n\n\u003e **@param** {number} blur effect quality\n\n\u003e **@param** {varargs} additional parameters sent to the contents drawing function\n\nExample:\n```lua\nlocal WIDTH, HEIGHT = 200, 50\nlocal PANEL = 'out_of_ammo'\nlocal LOCALE = 'Out of ammo'\nlocal FONT, COLOUR = 'holohud_med_sm', Color( 255, 0, 0 )\nlocal ALPHA = 0.5\n\n--[[\n  Draw the same as before, but with the panel being red and slightly\n  transparent\n]]\nlocal function DrawPanel( y )\n\n  HOLOHUD:DrawFragmentAlignSimple( ( ScrW() * .5 ) - ( WIDTH * .5 ), ScrH() * y, WIDTH, HEIGHT, function( x, y, w, h )\n\n    HOLOHUD:DrawText( x + ( w * .5), y + ( h * .5 ), LOCALE, FONT, COLOUR, HOLOHUD:GetHighlight(PANEL), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )\n\n  end, PANEL, TEXT_ALIGN_TOP, COLOUR, ALPHA )\n\nend\n```\n\n### Add a number/text/texture highlighting\n\n\"Highlighting\" refers to when a number/text/texture brights for a while and then goes back to normal.\n\n`HOLOHUD:AddHighlight( id )`\n\u003e **CLIENT**\n\n\u003e Adds a highlight\n\n\u003e **@param** {string} identifier\n\nExample:\n```lua\nHOLOHUD:AddHighlight( 'out_of_ammo' )\n```\n\n### Trigger a number/text/texture highlighting\n\n`HOLOHUD:TriggerHighlight( id )`\n\u003e **CLIENT**\n\n\u003e Triggers a highlight effect\n\n\u003e **@param** {string} identifier\n\nExample:\n```lua\nlocal NAME = 'out_of_ammo'\nlocal TICK_RATE = 1\nlocal tick = 0\n\n--[[\n  Make the highlight blink every second\n]]\nlocal function AnimateHighlight()\n\n  if tick \u003c CurTime() then\n\n    HOLOHUD:TriggerHighlight( NAME )\n    tick = CurTime() + TICK_RATE\n\n  end\n\nend\n```\n\n### Get a highlight value\n\n`HOLOHUD:GetHighlight( id )`\n\u003e **CLIENT**\n\n\u003e Gets the current opacity of a highlight\n\n\u003e **@param** {string} identifier\n\n\u003e **@return** {number} opacity\n\nExample:\n```lua\nprint( HOLOHUD:GetHighlight( 'out_of_ammo' ) )\n```\n\nResult: `0`\n\n### Draw a number\n\n`HOLOHUD:DrawNumber( x, y, number, colour, zeros, bright, font, off, align, vertical_align )`\n\u003e **CLIENT**\n\n\u003e Draws a number that can be highlighted with a background\n\n\u003e **@param** {number} x position\n\n\u003e **@param** {number} y position\n\n\u003e **@param** {number} number to display\n\n\u003e **@param** {Color|nil} colour\n\n\u003e **@param** {string|nil} zeroes\n\n\u003e **@param** {number|nil} how opaque is the highlighting\n\n\u003e **@param** {string|nil} font to use\n\n\u003e **@param** {boolean|nil} whether the foreground shouldn't be drawn\n\n\u003e **@param** {TEXT_ALIGN_|nil} horizontal alignment\n\n\u003e **@param** {TEXT_ALIGN_|nil} vertical alignment\n\nExample:\n```lua\n-- draws a red number with the health at the middle left of the screen\n-- it will blink when the player is hurt, as it uses the 'health' highlight, added by default\n-- this is an example using ALL parameters, which is not always needed\nHOLOHUD:DrawNumber( ScrW() * .25, ScrH() * .5, LocalPlayer():Health(), Color( 255, 100, 100 ), '0000', HOLOHUD:GetHighlight('health'), 'holohud_main', false, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )\n```\n\n### Draw text\n\n`HOLOHUD:DrawText(x, y, text, font, colour, bright, align, vertical_align, off, alpha)`\n\u003e **CLIENT**\n\n\u003e Draws a text\n\n\u003e **@param** {number} x position\n\n\u003e **@param** {number} y position\n\n\u003e **@param** {string} text to draw\n\n\u003e **@param** {string|nil} font to use\n\n\u003e **@param** {Color|nil} colour\n\n\u003e **@param** {number|nil} how opaque is the highlighting\n\n\u003e **@param** {TEXT_ALIGN_|nil} horizontal alignment\n\n\u003e **@param** {TEXT_ALIGN_|nil} vertical alignment\n\n\u003e **@param** {boolean|nil} should effects like chromatic aberration and highlighting NOT draw\n\n\u003e **@param** {number|nil} opacity\n\nExample:\n```lua\n-- draws a green text with the player's name on the top center of the screen\n-- it will blink when the player is hurt, as it uses the 'health' highlight, added by default\n-- this is an example using ALL parameters, which is not always needed\nHOLOHUD:DrawText( ScrW() * .5, ScrH() * .25, LocalPlayer():Name(), 'holohud_small', Color( 100, 255, 100 ), HOLOHUD:GetHighlight('health'), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, false, 150 )\n```\n\n### Add an element\n\n`HOLOHUD.ELEMENTS:AddElement( id, title, subtitle, hide_elements, default_config, draw_function, enabled )`\n\u003e **CLIENT**\n\n\u003e Adds an element to the HUD, both to the customization menu and the drawing loop\n\n\u003e **@param** {string} unique ID\n\n\u003e **@param** {string} name of the element\n\n\u003e **@param** {string} subtitle or description\n\n\u003e **@param** {table|nil} which HL2 HUD elements should be hidden when this one is enabled\n\n\u003e **@param** {table} configuration parameters and their default values\n\nStructure: `name`, `desc` (optional), `value`, `options` (numeric value only), `minValue` (numeric value only), `maxValue` (numeric value only)\n\n\u003e **@param** {function|nil} drawing function\n\nAccepts one parameter which is a function used to access configuration.\n\n\u003e **@param** {boolean|nil} whether it should be enabled by default\n\nExample:\n\n```lua\n--[[\n  Add a new element that says 'Out of ammo' when out of ammo\n  This example uses functions previously declared on the other examples\n]]\nHOLOHUD.ELEMENTS:AddElement('out_of_ammo',\n  \"Out of ammo\",\n  \"Displays a label when you're out of ammunition\",\n  nil, -- don't override any CHud element\n  {\n    y = { name = 'Vertical position', value = 0.8, minValue = 0, maxValue = 1 }\n  },\n  function( config )\n\n    TriggerOutOfAmmoPanel()\n    AnimateHighlight()\n    DrawPanel( config('y') )\n\n  end\n)\n```\n\n### 'Out of ammo' element full example\n```lua\nif CLIENT then\n\n  local PANEL = 'out_of_ammo'\n  local WIDTH, HEIGHT = 220, 50\n  local LOCALE = 'OUT OF AMMO'\n  local FONT, COLOUR = 'holohud_med_sm', Color( 255, 0, 0 )\n  local TICK_RATE = 1\n\n  local tick = 0\n\n  HOLOHUD:AddFlashPanel( PANEL )\n  HOLOHUD:AddHighlight( PANEL )\n\n  --[[\n    Make the highlight blink every second\n  ]]\n  local function AnimateHighlight()\n\n    if tick \u003c CurTime() then\n\n      HOLOHUD:TriggerHighlight( PANEL )\n      tick = CurTime() + TICK_RATE\n\n    end\n\n  end\n\n  --[[\n    Trigger the panel 'out_of_ammo' when you're out of ammo\n  ]]\n  local function TriggerOutOfAmmoPanel()\n\n    local weapon = LocalPlayer():GetActiveWeapon()\n\n    if not IsValid( weapon ) or ( weapon:GetPrimaryAmmoType() \u003c= 0 and weapon:GetSecondaryAmmoType() \u003c= 0 ) then return end\n\n    local clip, reserve, alt = weapon:Clip1(), LocalPlayer():GetAmmoCount( weapon:GetPrimaryAmmoType() ), LocalPlayer():GetAmmoCount( weapon:GetSecondaryAmmoType() )\n\n    HOLOHUD:SetPanelActive( PANEL, clip \u003c= 0 and reserve \u003c= 0 and alt \u003c= 0 )\n\n  end\n\n  --[[\n    Draw contents\n  ]]\n  local function DrawPanel( y )\n\n    HOLOHUD:DrawFragmentAlignSimple( ( ScrW() * .5 ) - ( WIDTH * .5 ), ScrH() * y, WIDTH, HEIGHT, function( x, y, w, h )\n\n      HOLOHUD:DrawText( x + ( w * .5), y + ( h * .5 ), LOCALE, FONT, COLOUR, HOLOHUD:GetHighlight(PANEL), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )\n\n    end, PANEL, TEXT_ALIGN_TOP )\n\n  end\n\n\n  --[[\n    Add a new element that says 'Out of ammo' when out of ammo\n    This example uses functions previously declared on the other examples\n  ]]\n  HOLOHUD.ELEMENTS:AddElement('out_of_ammo',\n    \"Out of ammo\",\n    \"Displays a label when you're out of ammunition\",\n    nil, -- don't override any CHud element\n    {\n      y = { name = 'Vertical position', value = 0.8, minValue = 0, maxValue = 1 }\n    },\n    function( config )\n\n      TriggerOutOfAmmoPanel()\n      AnimateHighlight()\n      DrawPanel( config('y') )\n\n    end\n  )\n\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDyaMetR%2Fholohud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDyaMetR%2Fholohud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDyaMetR%2Fholohud/lists"}