22 May 2015
Writing Plugins in Pure Lua
Continuing our theme of making plugins more open, we want to make plugin development better by simplifying the way you package plugins written in pure Lua.
Previously, if you wanted to build a plugin, even if it only contained pure Lua code, you had to package it inside a native binary. This meant embedding the Lua bytecode into native source and compiling that into a native binary for each device platform (iOS, Android, etc) and each simulator platform (Mac and Win32)
Project Templates for Plugin Development
Today, we are offering you project templates that allow you to use Corona SDK, so that you can avoid all of that hassle. This way, you can easily write plugins and distribute them in the Corona Store as free plugins (and later this year, as purchasable plugins).
We have posted 2 plugin project templates on github:
These project templates are designed so you can edit the plugin’s Lua code just like you would a normal Corona project. Also, we made sure that you can use them on both Mac and Windows. For example, the helper scripts have both Mac and Win variants, like the one to create a new plugin project:
create_project.sh (Mac) and
Packaging Plugins for Distribution
For Corona Store distribution, we’ve also included packaging scripts (
build.sh for Mac and
build.bat for Win) that allow you to package your plugin for submission to the Corona Store. This includes logistics like directory folder structure, a stub metadata file for you to fill in, compiling Lua sources down to bytecode, etc. Full details on submission/packaging guidelines are in the respective README’s for each template.
Once a plugin is on the Corona Store, the plugins get bundled into the final
.apk automatically by the Corona Build Server.
If you are working on a plugin, we are accepting applications for free plugins (support for purchasable plugins coming later this year): Corona Store application form
As part of distributing a plugin, you’ll want to write plugin documentation. To make this as easy as possible, we’ve created documentation templates that you can fork on Github, each corresponding to the plugin project templates I mentioned earlier:
When you use these doc templates, you get web hosting for free. All you have to do is create a public Github repo and the Github site renders the HTML for you.
Useful for personal/private development too
We think these project templates should also be used more generally, even if you are just creating Lua modules for your own app or game project.
When you create a new plugin project, you may notice that the actual plugin files look just like the standard Lua-based module you might write in your own project.
The differences are merely structural, rather than technical. They may seem small, but over time will help you be more productive, such as being able to test this module separately from your actual Corona app project. That clean separation also means you’ll be able to use it multiple Corona app projects without worrying about some accidental code dependency being injected.
And who knows? You might decide to publish this module someday as a plugin on the Corona Store. In that case, there are already scripts that come with the project, ready to package your plugin for submission.