Yeah, I actually recently tried making a game in Lua using LOVE2D, and then making the same one in C with Raylib, and I didn't feel like Lua itself gave me all that much. I don't think Lua is best for game logic so much as it's the easiest language to embed in a game written in C or C++. That said, maybe some of its unique features, like its coroutines, or stuff relating to metatables, could be useful in defining game logic. I was writing very boring, procedural, occasionally somewhat object-oriented code either way.
Lua would definitely help with iteration times vs. C/C++/Rust but C# compiles very quickly. Especially in Unity where you have an editor that keeps assets cached and can hot reload code changes (with a plugin).
Coroutines can definitely be very useful for games and they're also available in C#.
What makes Lua the best for game logic? You don't even have types to help you out with Lua.
Yeah, I actually recently tried making a game in Lua using LOVE2D, and then making the same one in C with Raylib, and I didn't feel like Lua itself gave me all that much. I don't think Lua is best for game logic so much as it's the easiest language to embed in a game written in C or C++. That said, maybe some of its unique features, like its coroutines, or stuff relating to metatables, could be useful in defining game logic. I was writing very boring, procedural, occasionally somewhat object-oriented code either way.
Lua would definitely help with iteration times vs. C/C++/Rust but C# compiles very quickly. Especially in Unity where you have an editor that keeps assets cached and can hot reload code changes (with a plugin).
Coroutines can definitely be very useful for games and they're also available in C#.
Stuff that hooked me:
you integrate it tightly with the engine so it only does game logic, making files small and very quick and easy to read.
platform independent, no compiling, so can modify it in place on a release build of the game.
the "everything is a table" approach is very easy to concept mentally means even very inexperienced coders can get up and running quickly.
great exception handling, which makes most release time bugs very easy to diagnose and fix.
All of which means you spend far more time building game logic and much, much less time fighting the programming language.
Heres my example of a 744 flight data recorder (the rest of the 744 logic is in the containing folders)
https://github.com/mSparks43/747-400/blob/master/plugins/xtl...
All asynchronously multithreaded, 100% OS independent.
FWIW if you really want to be able to edit code in-place on a live system, you can do that in C# with Roslyn without all that much effort.
So much so, in fact, that it can be bolted onto an existing game written in C#. I did exactly that for Bannerlord: https://www.nexusmods.com/mountandblade2bannerlord/mods/1651
1 reply →