{"id":13744929,"url":"https://github.com/chadrem/easy_lua","last_synced_at":"2025-03-22T19:42:34.738Z","repository":{"id":15511177,"uuid":"18245396","full_name":"chadrem/easy_lua","owner":"chadrem","description":"Easy Lua is the simplest way to add Lua scripts to your Adobe Flash or ActionScript project.","archived":false,"fork":false,"pushed_at":"2014-11-05T17:22:40.000Z","size":887,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-27T23:42:21.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chadrem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-29T16:35:32.000Z","updated_at":"2024-12-03T11:28:45.000Z","dependencies_parsed_at":"2022-09-16T04:41:30.216Z","dependency_job_id":null,"html_url":"https://github.com/chadrem/easy_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/chadrem%2Feasy_lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chadrem%2Feasy_lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chadrem%2Feasy_lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chadrem%2Feasy_lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chadrem","download_url":"https://codeload.github.com/chadrem/easy_lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245013932,"owners_count":20547177,"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":[],"created_at":"2024-08-03T05:01:18.655Z","updated_at":"2025-03-22T19:42:34.705Z","avatar_url":"https://github.com/chadrem.png","language":"ActionScript","readme":"# Easy Lua\n\nEasy Lua is the simplest way to add [Lua](http://www.lua.org/) scripts to your Adobe Flash or ActionScript project.\nIt builds on top of the excellent Lua port that ships with Adobe's open source [CrossBridge](https://github.com/adobe-flash/crossbridge) project.\n\n#### Features\n\n- Hides all the low level Lua C API details in one easy to use class.  No Lua C API knowledge required.\n- Works with all ActionScript palatforms (web, desktop, and mobile).\n- Automatically converts basic ActionScript variables to Lua equivalents (and back again).\n- Supports multiple instances of the Lua interpretter so that you can sandbox separate scripts.\n- Simplifies the process of loading embedded Lua scripts in your project.\n\n#### Todo\n\n- Currently ActionScript can call Lua code (and receive a return value), but Lua code can't call ActionScript directly.\n\n## Installation\n\nInstallation is simple.\nFirst, copy the files in the `src` and `lib` directories to your project.\nSecond, tell the compiler to link your code to `lib/lua.swc`.\n\n## Basic Usage\n\n#### Initialization\n\nCreate an instance of the `EasyLua` class:\n\n    var easyLua:EasyLua = new EasyLua();\n\n#### Evaluating Lua code\n\nCall the `eval` method to execute some Lua code.  This code defines a `helloWorld` function that returns a string:\n\n    easyLua.eval(\"function helloWorld() return 'hello world' end\");\n\nCall the function that we defined above and return the result back to ActionScript:\n\n    var result:String = easyLua.eval(\"return helloWorld()\");\n\nYou must explicity add the `return` keyword to tell Lua to return the value back to ActionScript.\nFailure to do so will result in no value being returned.\nThis way you get to decide if you want to deal with the conversion overhead.\nMost basic Lua types (nil, numbers, strings, booleans, and tables) are supported.\nAn exception will be raised if you try to return an unsupported type.\n\n#### Calling Lua functions\n\nEasy Lua provides a helper method called `evalFunction` to simplify all of the above.\nUnlike `eval`, this method will automatically include a `return` and convert any arguments to their Lua equivalents.\n\n    easyLua.eval(\"function helloWorldImproved(arg) return arg end\");\n    var result:Object = easyLua.evalFunction('helloWorldImproved', { foo: 'bar' });\n\n#### Clean-up\n\nYou must manually `dispose` instances of Easy Lua when you are finished with them.\nThis ensures that the resources used by Lua are released.\n\n    easyLua.dispose();\n\n## Embedding Scripts\n\nMost non-trivial Lua programs store their code in files.\nEasy Lua integrates with ActionScript's embedded asset feature where each asset file becomes its own class.\nYou can then load these embedded assets either manually or using the CrossBridge virtual file system (VFS).\n\n#### Embedding assets\n\nFirst you will need to embed your scripts just like you would embed any other asset.\nBelow is an example `asset/hello.lua` that you would create in your project's root folder:\n\n    function helloWorld()\n      return \"hello world\"\n    end\n\nBelow is an example `src/MyAssets.as` where you define all of your asset classes.\n\n    package\n    {\n      public class MyAssets\n      {\n        [Embed(source=\"../asset/hello.lua\", mimeType=\"application/octet-stream\")]\n        public static var helloLuaScript:Class;\n      }\n    }\n\n#### Virtual file system (VFS)\n\nCrossBridge provides a VFS that lets you register files with Flash.\nThis is the recommended way to load files since it uses the standard Lua `require` syntax.\n\n    EasyLua.addAssetAsFile('hello.lua', MyAssets.helloLuaScript);\n    var easyLua:EasyLua = new EasyLua();\n    easyLua.eval(\"require 'hello'\");\n    var result:String = easyLua.eval(\"return helloWorld()\");\n\nNote that that `addAssetAsFile` is a static method.\nThis is because the VFS is shared between all instances of the `EasyLua` class.\n\n#### Manual file loading\n\nIn some cases you may want to load scripts manually and avoid the VFS.\nThis can be accomplished with the `evalEmbedded` method:\n\n    var easyLua:EasyLua = new EasyLua();\n    easyLua.evalEmbedded(MyAssets.helloLuaScript);\n    var result:String = easyLua.eval(\"return helloWorld()\");\n\n## Lua table conversion\n\nIn Lua, tables can act as integer indexed arrays or as hashes (associative arrays).\nWhen Lua returns a table, Easy Lua tries to automatically convert it to the correct actionscript type (`Array` or `Object`).\nThe `autoConvertArrays` setter can disable this automatic conversion (and save some CPU cycles).\nTables will then always convert to `Object`:\n\n    easyLua.autoConvertArrays = false;\n\n## Stdout and Lua's print()\n\nBasic support for Lua's `print` function exists.\nAll output is routed to ActionScript's `trace` function.\nIn practice, this is useful for basic debugging of Lua code while running inside of an ActionScript IDE or debugger (such as Adobe's Flash Builder).\nMore advanced usage will require you to modify the `Console.as` class.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","funding_links":[],"categories":["Unsorted"],"sub_categories":["Other API"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchadrem%2Feasy_lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchadrem%2Feasy_lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchadrem%2Feasy_lua/lists"}