Luny Tanks – The Code Is Lua! :)
I ported Unity Learn’s Tanks! project to Luny. It’s a major milestone for Luny – the Lua solution for Unity.
The Code Is Lua, Literally!
You read that right: Lua, not lava!
The demo runs Lua code!😀
In the browser!!😃
At a whopping 200+ fps!!!😄
Play the web demo! You can also try the Windows x64 build (IL2CPP) if you trust my authoritah. Both are development builds.
Runtime Script Editor
Just for demonstration purposes, I added a runtime script editor that enables you to edit the FireShell
function at runtime:

I provided a template that you can quickly comment in some lines to create a multi-shot!
Note: You can Ctrl+A to select all text, then use Ctrl+C/Ctrl+V to copy/paste it to and from a text editor of your choice. If you create a compile error, it’ll show up at the bottom. If there’s a runtime error, it’ll pop up the ingame error console while playing.
Compiling A Lua String
This is the code that compiles the user’s TMP_InputField
script – the above FireShell()
script:
public Boolean CompileUserScript(String script)
{
var success = false;
try
{
Luny.Singleton.Lua.DoString(script, "FireShell.lua");
success = true;
}
catch (Exception e)
{
m_ErrorText.text = e.Message;
}
return success;
}
Never mind the Singleton
. I’ll make it so that you can have multiple Lua states.
The Lua Scripts
Here are the (most important) Lua scripts that make the game tick .. or ‘track’. Original C# comments and logic flow left mostly intact:
- LunyCameraControl.lua (camera, obviously)
- LunyGameManager.lua (nested coroutines)
- LunyTankManager.lua (not a MonoBehaviour)
- LunyTankAI.lua (the longest script)
- LunyTankMovement.lua (a bit of everything)
- LunyTankShooting.lua (calls FireShell() which you can edit)
- LunyTankHealth.lua (some UGUI)
- LunyTankInputUser.lua (new input system)
- LunyShellExplosion.lua (audio and particle systems)
IDE Support for Lua
For most IDEs there’s at least one plugin that enables Lua support with syntax highlighting, autocompletion, error checking and more.
See the following list, ordered by how well each IDE works with and understands Unity:
- Lua extensions for Rider
- ..
- …
- ..
- …
- ….
- ..
- Lua extensions for Visual Studio
- …
- Lua extensions for Visual Studio Code
I currently use SumnekoLua but haven’t tried others yet.
Next Step
I will create automated bindings of the Unity API so you can experience programming Unity in Lua in full!
This will likely take me another month or two. Maybe more. But then it’s going to be ready for release!
Join my Patreon to not miss out!