{"id":21085108,"url":"https://github.com/tobitege/du-luac-template","last_synced_at":"2025-03-14T05:13:32.126Z","repository":{"id":209619008,"uuid":"724535427","full_name":"tobitege/DU-LuaC-template","owner":"tobitege","description":"Project template for developing LUA with DU-LuaC and Dual Universe","archived":false,"fork":false,"pushed_at":"2023-11-28T09:43:41.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T00:26:02.590Z","etag":null,"topics":["dualuniverse","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":false,"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/tobitege.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}},"created_at":"2023-11-28T09:27:14.000Z","updated_at":"2024-05-28T19:37:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d9dc14b-6978-490b-a9a7-e796996e34c8","html_url":"https://github.com/tobitege/DU-LuaC-template","commit_stats":null,"previous_names":["tobitege/du-luac-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobitege%2FDU-LuaC-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobitege%2FDU-LuaC-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobitege%2FDU-LuaC-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobitege%2FDU-LuaC-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobitege","download_url":"https://codeload.github.com/tobitege/DU-LuaC-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526944,"owners_count":20305115,"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":["dualuniverse","lua"],"created_at":"2024-11-19T20:29:45.902Z","updated_at":"2025-03-14T05:13:32.099Z","avatar_url":"https://github.com/tobitege.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DU-LuaC-template\n\n## Introduction\n\nThis is a project template for using [DU-LuaC](https://github.com/wolfe-labs/DU-LuaC)\nto compile LUA files into \"ready-to-install\" json (or .conf) file for Dual Universe.\n**I love that tool! :)**\n\n**As a primer to DU-LuaC:**\nIt compiles and packages LUA files according to the contents of the \"*project.json*\" file.\nIn that file one ore more entry points can be defined, each representing separate lua script files.\nDuring compilation (it will report syntax errors), all \"*require*\" commands\nwill be combined into a single collection and end up on the programming board\nin the **2nd**(!) library.onStart section.\nThe remainder of the main script will be placed as usual in the \"unit.onStart\" section.\n\nBy default, pretty much all global elements in the LUA editor (library, unit, player, system...)\nwill get one or multiple DU-LuaC event handlers assigned (each is just a single line)\nso that the main script can assign code to them at runtime.\n\nThe \"out\" folder contains the latest builds of all entry points in the \"development\"\nand \"release\" sub-folders. The \"development\" version keeps the source\nin a readable format whereas the \"release\" version is a much compressed\nversion to save space on the programming board (ingame), but it is no \"minified\" as such.\nThe included Windows cmd file \"b.cmd\" starts the DU-LuaC build for the development target\nand copies the \"main.json\" content to the clipboard (see command line parameter).\n\nSome lines in the code are for allowing debugging of the script(s) within VSCode,\nwhich requires 3rd party extentions like \"Lua Debug\" (actoboy168) or \"Local Lua Debugger\"\n(Tom Blind); also recommend \"Lua\" (sumneko) as a language server.\n\nThe \"globals\" file references in commented out lines \"mocks\", which are not part\nof this repo (yet), i.e. code to \"emulate\" DU objects so scripts won't fail\nwhen run/debugged outside of DU's lua environment.\n\nThe \"main.lua\" files include a lot of comments to describe what code is being used where and why.\n\nIncluded in the \"util\" folder is a slightly enhanced version of the \"Codex.lua\"\ngenerated originally by DU-LuaC. This version has some custom annotations at\nthe top to avoid language server notifications/errors when working in VSCode.\n\n## Required elements\n\n- 1 programming board\n- 1 databank\n- 1 screen (any size)\n\nThe project file (project.json) has 2 entry points: \"main\" and \"mainWithFixedSlots\".\nBiggest difference is that the latter defines fixed, named slots, i.e. elements like\nthe screen and databank must be linked in a specific order.\nThis approach is required when an event for the screen needs to be assigned,\nwhich does not work with dynamic link detection. DU-LuaC needs to apply its\nevent handlers during compilation time to that screen's slot.\n\nThe first scipt (\"main\") has \"empty\" slots in the project file as it uses dynamic\nslot detection during runtime (see \"startup.lua\"). It can assign code to the\nonInputText event during runtime since the \"system\" slot obviously always\nmust exist within DU constructs.\n\n## Setup\n\nAll elements need to be deployed on the same construct, as usual.\n\n- Deploy programming board, a screen and a databank.\n- Link the screen, then the databank to the board (important for the 2nd script!).\n- Install onto the board on of the \"main.json\" or \"mainWithFixedSlots.json\" scripts\n    from the \"out\\development\" folder.\n- The \"out\\release\" folder only contains files if project was compiled\n    without a parameter (\"du-lua build\" in console) or explicitly for release.\n\n## Script Installation\n\n**General installation steps in DU:**\n\nFor *programming boards* open a .json file in the above mentioned out\\development\nfolder, copy its full content to clipboard and in game right click the programming\nboard to get the \"Advanced\" menu popup.\nThen click the menu item \"**Paste Lua configuration from clipboard**\" to have DU\ninstall the script onto the board.\nShould there appear a red notification ingame, then the slots configuration might be wrong.\n\n*For a screen* script (not part of this repo!), copy the scripts' content to the clipboard.\nThen either\n-\u003e point at the screen and hit CTRL+L\nOR\n-\u003e right click the screen, select the \"Advanced\" menu item, click \"Edit content\".\nThe above opens the screen's LUA editor into which the script can now be pasted into.\nThen hit \"Apply\" to save it and turn on the screen (if not already done).\nIf successful, a notification \"LUA script loaded\" should appear in game in the bottom screen.\n\n## Example compiler output\n\nExecuting the \"b.cmd\" file will call the DU-LuaC compiler and produce output similar to below text.\n\nThe extra parameter \"--copy=development/main\" will cause the resulting\nJSON file for the \"main\" script to be copied to the Windows clipboard,\nso it can then immediately be pasted in-game onto a programming board.\nThis is a huge timesaver during development!\n\n```D:\\github\\DU-LuaC-template\u003edu-lua build development --copy=development/main\nLua CLI Utility for Dual Universe v1.2.1 by Wolfe Labs @ Node v20.5.1\n\n[BUILDER] Starting build main for target development...\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\main.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\globals.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\startup.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\common-library.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\main-sys_onInputText.lua  \n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\main-onStart.lua\n[BUILDER] Generating output files for target development...\n[BUILDER] JSON build size: 14.59 kB out of 200.00 kB (7.29%)\n[BUILDER] CONF build size: 11.95 kB out of 180.00 kB (6.64%)\n[SUCCESS] Build development/main successfully copied to clipboard!\n\n[BUILDER] Starting build mainWithFixedSlots for target development...\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\mainWithFixedSlots.lua    \n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\globals.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\common-library.lua        \n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\main-screen.onOutputChanged.lua\n[COMPILE] Compiling file: D:\\github\\DU-LuaC-template\\lua\\main-onStart.lua\n[BUILDER] Generating output files for target development...\n[BUILDER] JSON build size: 14.41 kB out of 200.00 kB (7.21%)\n[BUILDER] CONF build size: 10.82 kB out of 180.00 kB (6.01%)\n\n[SUCCESS] Build completed successfully!\n```\n\n### Credits\n\nBig thanks to Matt for creating DU-LuaC and helping out when I had questions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobitege%2Fdu-luac-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobitege%2Fdu-luac-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobitege%2Fdu-luac-template/lists"}