{"id":20660993,"url":"https://github.com/liatemplates/lua","last_synced_at":"2025-07-19T20:38:28.439Z","repository":{"id":107256844,"uuid":"224441432","full_name":"LiaTemplates/Lua","owner":"LiaTemplates","description":"Lua interpreter and VM to be used in LiaScript for teaching programming","archived":false,"fork":false,"pushed_at":"2019-11-27T13:51:20.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T12:16:34.374Z","etag":null,"topics":["coding","liascript","liascript-template","lua","oer"],"latest_commit_sha":null,"homepage":"https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/Lua/master/README.md","language":null,"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/LiaTemplates.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":"2019-11-27T13:50:28.000Z","updated_at":"2024-02-20T13:56:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"46f7b8fb-8161-4fcd-837e-631ad8d2c353","html_url":"https://github.com/LiaTemplates/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/LiaTemplates%2FLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaTemplates","download_url":"https://codeload.github.com/LiaTemplates/Lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242788055,"owners_count":20185209,"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":["coding","liascript","liascript-template","lua","oer"],"created_at":"2024-11-16T19:06:44.802Z","updated_at":"2025-03-10T04:25:17.415Z","avatar_url":"https://github.com/LiaTemplates.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    LiaScript@web.de\n\nversion:  0.0.1\n\nlanguage: en\n\nnarrator: US English Male\n\nlogo:     https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Lua-Logo.svg/480px-Lua-Logo.svg.png\n\ncomment:  A fully functional Lua-VM based on the emscripten port of\n          https://daurnimator.github.io\n\nscript:   https://daurnimator.github.io/lua.vm.js/js/lua.js\n          https://daurnimator.github.io/lua.vm.js/lua.vm.js\n\n\n@Lua.eval\n\u003cscript\u003e\n  emscripten.print = function(x) {\n    console.log(x);\n  }\n  L.execute(`@input`)\n\u003c/script\u003e\n@end\n--\u003e\n\n# Lua - Template\n\n\n                         --{{0}}--\nThis document defines some basic macros for applying the JavaScript Lua\ninterpreter and VM https://daurnimator.github.io in\n[LiaScript](https://LiaScript.github.io) to make Markdown code-blocks\nexecutable.\n\n__Try it on LiaScript:__\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/Lua/master/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaTemplates/Lua\n\n                         --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the URL of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#3). And of course, you could also clone this project and change\nit, as you wish.\n\n                           {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/liaTemplates/Lua/master/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n## `@LUA.eval`\n\n                         --{{0}}--\nAdd the macro `@LUA.eval` to the end of a single Lua code-block to make it\nexecutable and editable in LiaScript. The current code gets evaluate by the\nJavaScript Lua interpreter and the result is shown in a console below.\n\n\n``` lua\nprint('hello' .. ' ' .. 'world!') -- This is Lua!\n\nprint(js.global:eval('[0,1,2,3,4,5][3]')) -- Run JS from Lua\n\n-- Interact with the page using Lua\n\nlocal screen = js.global.screen\nprint(\"you haz \" .. (screen.width*screen.height) .. \" pixels\")\n\nlocal window = js.global -- global object in JS is the window\nwindow:alert(\"hello from lua!\")\nwindow:setTimeout(function() print('hello from lua callback') end, 2500)\n\nlocal document = js.global.document\nprint(\"this window has title '\" .. document.title .. \"'\")\n\n-- call constructors (global, or as properties of other objects)\nprint(\"i made an ArrayBuffer of size \" .. js.new(js.global.ArrayBuffer, 20).byteLength)\n-- print(\"i made an ArrayBuffer of size \" .. js.global.ArrayBuffer:new(20).byteLength)\n\nprint(\"time iz \" .. js.global.Date.now()) -- call with no arguments\n\nprint('done!')\n```\n@Lua.eval\n\n\n## Implementation\n\n                         --{{0}}--\nThe code shows how the macro is implemented by calling the macro `@Lua.eval`.\nThe `@input` macro gets substituted by the current input code. The script\ncommands at the top define the references to the Lua JavaScript implementations\nthat need to be called to load the interpreter and VM.\n\n``` js\nscript:   https://daurnimator.github.io/lua.vm.js/js/lua.js\n          https://daurnimator.github.io/lua.vm.js/lua.vm.js\n\n\n@Lua.eval\n\u003cscript\u003e\n  emscripten.print = function(x) {\n    console.log(x);\n  }\n  L.execute(`@input`)\n\u003c/script\u003e\n@end\n```\n\n                         --{{1}}--\nIf you want to minimize loading effort in your LiaScript project, you can also\ncopy this code and paste it into your main comment header, see the code in the\nraw file of this document.\n\n{{1}} https://raw.githubusercontent.com/liaTemplates/Lua/master/README.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Flua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliatemplates%2Flua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Flua/lists"}