{"id":18456317,"url":"https://github.com/martmists-gh/klua","last_synced_at":"2025-04-22T19:26:52.326Z","repository":{"id":212134207,"uuid":"729967524","full_name":"Martmists-GH/KLua","owner":"Martmists-GH","description":"[WIP] A Lua interpreter for Kotlin","archived":false,"fork":false,"pushed_at":"2023-12-15T23:44:12.000Z","size":451,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T14:58:23.161Z","etag":null,"topics":["interpreter","kotlin","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-4-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Martmists-GH.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":"2023-12-10T22:19:22.000Z","updated_at":"2024-10-27T14:23:33.000Z","dependencies_parsed_at":"2024-11-06T08:11:13.602Z","dependency_job_id":null,"html_url":"https://github.com/Martmists-GH/KLua","commit_stats":null,"previous_names":["martmists-gh/klua"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martmists-GH%2FKLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martmists-GH%2FKLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martmists-GH%2FKLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martmists-GH%2FKLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Martmists-GH","download_url":"https://codeload.github.com/Martmists-GH/KLua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250307795,"owners_count":21409147,"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":["interpreter","kotlin","lua"],"created_at":"2024-11-06T08:11:08.694Z","updated_at":"2025-04-22T19:26:52.303Z","avatar_url":"https://github.com/Martmists-GH.png","language":"Lua","readme":"# KLua\n\nKLua is a Lua interpreter written in Kotlin, based on Kotlinx.coroutines.\nIt currently only supports JVM, but should be easy to port once context receivers become available on other platforms.\n\n## Features\n\n- Based on Lua 5.4.6\n- Coroutines are implemented natively using Kotlinx.coroutines\n\n## Usage\n\nRunning snippets of Lua is simple:\n\n```kotlin\nval engine = LuaInterpreter()\nengine.execute(\"print('Hello, world!')\")\n```\n\nHowever, in some cases you may want to safeguard your application from malicious code, by removing e.g. io access.\n\n```kotlin\nval engine = LuaInterpreter()\nengine.execute(\"print('Hello, world!')\") { env: TTable -\u003e\n    env[\"io\"] = TNil  // Remove io library from _ENV (= _G)\n}\n```\n\nRegistering custom types or methods is also fairly straightforward:\n\n```kotlin\nclass Counter {\n    var value = 0\n}\n\nval engine = LuaInterpreter()\nengine.execute(\"...\") { env: TTable -\u003e\n    env[\"my_function\"] = TFunction { args: List\u003cTValue\u003e -\u003e\n        val action = args.argument(0, TNumber::class)\n        val value = action.value.toLong()\n        when (value) {\n            0L -\u003e return_(TString(\"Hello, world!\"))  // Return a value\n            1L -\u003e yield(TString(\"Hello, world!\"))  // Yield a value\n            else -\u003e error(\"Invalid action\")  // Emit an error\n        }\n    }\n    \n    env[\"some_counter\"] = TUserdata(Counter())  // Methods can be added using the __index metamethod\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartmists-gh%2Fklua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartmists-gh%2Fklua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartmists-gh%2Fklua/lists"}