{"id":24678611,"url":"https://github.com/compuserscripts/lua-vgui-parser","last_synced_at":"2025-10-14T22:32:08.168Z","repository":{"id":270882267,"uuid":"911740354","full_name":"compuserscripts/Lua-VGUI-Parser","owner":"compuserscripts","description":"A robust Lua library for parsing Valve GUI (VGUI) resource files, specifically designed for LMAOBOX and Lua 5.1.","archived":false,"fork":false,"pushed_at":"2025-01-03T18:31:28.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T18:27:54.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compuserscripts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-03T18:24:12.000Z","updated_at":"2025-01-03T18:31:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"f255b8e1-9eb4-4148-81a2-3b3b36cdd749","html_url":"https://github.com/compuserscripts/Lua-VGUI-Parser","commit_stats":null,"previous_names":["compuserscripts/lua-vgui-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/compuserscripts/Lua-VGUI-Parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compuserscripts%2FLua-VGUI-Parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compuserscripts%2FLua-VGUI-Parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compuserscripts%2FLua-VGUI-Parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compuserscripts%2FLua-VGUI-Parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compuserscripts","download_url":"https://codeload.github.com/compuserscripts/Lua-VGUI-Parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compuserscripts%2FLua-VGUI-Parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021785,"owners_count":26087056,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-01-26T13:17:45.207Z","updated_at":"2025-10-14T22:32:08.163Z","avatar_url":"https://github.com/compuserscripts.png","language":"Lua","readme":"# Lua VGUI Parser\n\nA robust Lua library for parsing Valve GUI (VGUI) resource files, specifically designed for LMAOBOX and Lua 5.1. This library provides a complete toolkit for lexing, parsing, and manipulating VGUI resource files with support for preprocessing directives.\n\n## Features\n\n- Full VGUI resource file parsing\n- Support for #base preprocessing directives\n- Recursive file inclusion handling\n- Flag and property merging\n- Object-oriented design\n- Whitespace and comment handling\n- Robust error handling\n- File system traversal utilities\n\n## Installation\n\n1. Download `vgui.lua` and place it in your LMAOBOX scripts directory\n2. Require the module in your script:\n\n```lua\nlocal vgui = require('vgui')\n```\n\n## Usage\n\n### Basic Parsing\n\n```lua\n-- Parse a VGUI resource file\nlocal obj = vgui.VguiSerializer.fromFile(\"tf/custom/my_hud\", \"basechat.res\")\n\n-- Access properties\nlocal property = obj:get(\"propertyName\")\n\n-- Check if object has a value\nif obj:isValue() then\n    print(obj.value)\nend\n```\n\n### Recursive Directory Search\n\n```lua\n-- Find and parse basechat.res in custom directory\nlocal function findBaseChatRes(directory)\n    local baseChat = nil\n    filesystem.EnumerateDirectory(directory .. \"/*\", function(filename, attributes)\n        if attributes \u0026 E_FileAttribute.FILE_ATTRIBUTE_DIRECTORY ~= 0 then\n            if filename ~= \".\" and filename ~= \"..\" then\n                local result = findBaseChatRes(directory .. \"/\" .. filename)\n                if result then\n                    baseChat = result\n                end\n            end\n        elseif filename:lower() == \"basechat.res\" then\n            baseChat = directory .. \"/\" .. filename\n        end\n    end)\n    return baseChat\nend\n```\n\n### Pretty Printing\n\n```lua\nlocal function printVguiObject(obj, indent)\n    indent = indent or 0\n    local spacing = string.rep(\"  \", indent)\n\n    for name, prop in pairs(obj.properties) do\n        if prop:isValue() then\n            print(spacing .. name .. \" = \" .. tostring(prop.value))\n        else\n            print(spacing .. name .. \" {\")\n            printVguiObject(prop, indent + 1)\n            print(spacing .. \"}\")\n        end\n    end\nend\n```\n\n## Core Components\n\n### TokenType\n\nEnumeration of token types used in lexical analysis:\n- LeftBrace\n- RightBrace\n- Flag\n- String\n- Name\n\n### VguiObject\n\nMain class for representing VGUI elements:\n- Properties management\n- Flag comparison\n- Property merging\n- Value handling\n\n### Lexer\n\nHandles tokenization of input text:\n- Whitespace skipping\n- Comment handling\n- String parsing\n- Name and flag token generation\n\n### Parser\n\nConverts token stream into structured data:\n- Value parsing\n- Property list handling\n- Root object construction\n\n### Preprocessor\n\nHandles file inclusion and preprocessing:\n- #base directive support\n- Recursive file processing\n- Source provider interface\n\n## Advanced Features\n\n### Flag Handling\n\n```lua\n-- Compare flags between objects\nlocal matches = obj1:compareFlags(obj2)\n\n-- Get name and flags as a key\nlocal key = obj:getNameFlagKey()\n```\n\n### Property Merging\n\n```lua\n-- Merge properties from another object\nlocal success = obj1:tryMerge(obj2)\n\n-- Add or merge a single property\nobj:mergeOrAddProperty(property)\n```\n\n## Error Handling\n\nThe library includes robust error handling for common issues:\n- Missing files\n- Invalid syntax\n- Malformed tokens\n- Recursive inclusion loops\n\n## Requirements\n\n- Lua 5.1\n- LMAOBOX\n- File system access permissions\n\n## Limitations\n\n- Only supports VGUI resource file format\n- Requires LMAOBOX environment\n- Limited to local filesystem access\n\n## Credits\n\nhttps://github.com/dresswithpockets/Vgui - For inspiration\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompuserscripts%2Flua-vgui-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompuserscripts%2Flua-vgui-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompuserscripts%2Flua-vgui-parser/lists"}