{"id":20612855,"url":"https://github.com/alphamodder/include-lua","last_synced_at":"2025-04-15T07:09:40.433Z","repository":{"id":57634520,"uuid":"178344118","full_name":"AlphaModder/include-lua","owner":"AlphaModder","description":"include-lua is a crate that allows the embedding of a lua source tree into a Rust application binary.","archived":false,"fork":false,"pushed_at":"2019-06-08T11:32:00.000Z","size":13,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T07:09:34.923Z","etag":null,"topics":["lua","proc-macro","rlua","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlphaModder.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}},"created_at":"2019-03-29T06:16:04.000Z","updated_at":"2025-03-01T17:22:02.000Z","dependencies_parsed_at":"2022-09-16T04:12:08.790Z","dependency_job_id":null,"html_url":"https://github.com/AlphaModder/include-lua","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaModder%2Finclude-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaModder%2Finclude-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaModder%2Finclude-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaModder%2Finclude-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlphaModder","download_url":"https://codeload.github.com/AlphaModder/include-lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023723,"owners_count":21199960,"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":["lua","proc-macro","rlua","rust"],"created_at":"2024-11-16T11:08:05.927Z","updated_at":"2025-04-15T07:09:40.417Z","avatar_url":"https://github.com/AlphaModder.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# include-lua #\ninclude-lua is a crate that allows the embedding of a lua source tree into a Rust application binary. This tree can then be loaded into an [`rlua`](https://github.com/kyren/rlua) context, and code imported from it via `require`. \n\n## Basic Usage ##\nFirst, create an instance of the `LuaModules` struct via the macro `include_lua!`. This macro takes a string literal parameter specifying a directory, relative to your crate's `src` folder. All `.lua` files in this directory and its subdirectories will be included as loadable modules. \n\nOnce you've created a `LuaModules` struct, you can import it into an `rlua::Context` by calling `ctx.add_modules(modules)`. This is an extension method provided by a trait, so make sure you have a `use include_lua::*;` statement in your code. Once it has been called, any calls to `require` executed in that context will be able to load modules from the embedded source tree. \n\n## Advanced Usage ##\nIt is possible to specify a name to use for the `LuaModules` struct, which will appear in stacktraces from any code within it. Simply invoke the `include_lua` macro like `include_lua!(\"name\": \"path\")`, instead of just `include_lua!(\"path\")`.\n\nIf you would like to load modules in a custom environment for some reason, instead of `ctx.add_modules`, you can call `ctx.add_modules_with_env(modules, env)`, where `env` is a table that will be used as the `_ENV` value of all modules within the source tree.\n\nThe methods `ctx.make_searcher(modules)` and `ctx.make_searcher_with_env(modules, env)` are also available. They produce a piece of userdata that in Lua code, acts like a function to load a module from the source tree by name.\n\nAs they are lower-level methods, values returned by `make_searcher` or `make_searcher_with_env` do not cache modules like `require`. This means that if you want to avoid multiple calls with the same name loading multiple copies of the same module you will have to implement a wrapper in your lua code. \n\n## Example ##\nSee [example/main.rs](https://github.com/AlphaModder/include-lua/blob/master/example/src/main.rs) for a working example of the macro's use.\n\n## Caveats ##\nCurrently, this crate does not support paths that contain non-unicode characters. Any files along these paths will be omitted from an `include_lua!` call.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphamodder%2Finclude-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falphamodder%2Finclude-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphamodder%2Finclude-lua/lists"}