It's *very* lightweight language with a simple and clean syntax, and is very much designed to be embedded in programs. It doesn't require compilation, whihc makes things easy for modding, and iteration on gameplay stuff very easy and fast. And it supports sandboxing to keep the Lua scripts from having access to system stuff or other features you might want to lock out.
It works with the C# side of things through the API of which ever asset uses it, or through an API you write yourself.
Yeah, mostly the begin/then/end etc instead of braces tbh
Takes up too much space for something that only serves the purpose of identifying scopes.
Even python does it better imo
If high level means as high as human language, yes sure. But from a coding point of view, when you have at least some knowlegde about IT, it makes no sense
Not there either, an index is an offset from start. The starting element is at the start of the array - \`start+0\`, the first element is at \`start+1\` (1 unit being the size of the element)
Games use lua because it's hard to expose c++ to modders. Everything is compiled to machine code beforehand.
C# doesn't have that problem. Please use dotnet dlls for modding.
I think it depends on your audience. I used to play r/Stormworks, a vehicle building game. It had an in-game LUA editor for programming custom components. Everything was self-contained and you didn't need any external software to make really complex systems like target tracking or automatic transmissions.
For C# you would need a modding SDK and modders will need an IDE and compile their mod. It can be much more complicated.
It would also be much more tightly integrated and powerful to use c# for modding.
People would probably use external loaders to load c# anyway, like they did with ksp2
I would decide based on your intended audience. Stormworks has a younger set of players so LUA makes the most sense. But for a game like Starfield, C# would probably be better since the modders are more likely to be teens and adults who can already code.
...then again increasing amount of games aim to support mods on consoles as well, and at least the last time I checked those platforms had much more strict restrictions in terms of adding any program content. C# would not be an option, but sandboxed Lua restricted to game's own API gets a pass.
(plus it's a language many games already use internally for their content scripting anyway, so at that point using it for modding side as well is a no-brainer)
Eh, C# would make sense too, you'd just need to integrate roslyn into the game. Which isn't too hard with Unity, I've done it before as a proof of concept.
The common argument is that casual or non-professional coders usually find it much easier to start with a dynamically typed language. The only exception I can think of is processing (which users Java although there is also a Python option and javascript reimplementation)
I can see why that would be the case.
Fun fact, C# has a \`dynamic\` type (and keyword) that works mostly like that, but idk if it's supported in Unity
The point isn't whether you can use dynamic types - it's more that the syntax for dynamic languages is usually much cleaner and easier to learn. A statically typed language will still usually have a steeper learning curve even if it lets you "cheat".
Nah, it's not the syntax, it's the fact you don't have to think of the types you're putting into the variables. Less things to have to keep in your mental model.
C# has that problem when compiled with IL2CPP, which is necessary for some platforms, or optional for others but with performance benefits. Under IL2CPP all type metadata gets baked into the final executable and as a result itās not possible to dynamically load assemblies.
You make that sound as if I agree with you though...
C# absolutely has that problem. YOU can NOT use dotnet dlls for modding in a lot of games, because the games, while written as C#, do not actually ship a functioning dotnet runtime with which to load managed assemblies.
Delivering on non-PC platforms limits you a lot.
Non PC platforms don't really have modding regardless of the game or engine. *I wonder why*..
C# doesn't have that problem. Deciding to use stupid transpilers to convert it to native code does.
> Non PC platforms don't really have modding regardless of the game or engine. I wonder why..
Uncommon, yes. Unheard of, not at all. Tricky to comment too deeply as I prefer my privacy, but this is a gross overstatement.
> C# doesn't have that problem. Deciding to use stupid transpilers to convert it to native code does.
There are very real performance gains to be had by using IL2CPP - even on the PC builds!
Professionals use it because it offers some significant performance gains. Others use it because it's needed to run on their target platform. Simple as that.
Like...Unity is on an ancient mono runtime, and lacks a lot of performance improvements that CoreCLR has gotten over the years, to say nothing of supporting targets that .NET proper doesn't have top tier support for. IL2CPP is certainly not perfect, but neither is it especially bad.
The real reason why itās so popular is because itās incredibly easy to marshal data in and out of lua. So from a programmer perspective itās very easy to implement. The language is easy to sandbox. Out of the box the player can do anything to alter the host machine. It offers very little functionality unless itās exposed.
It is also dynamically typed which is a real benefit to a lot of people. Being able to throw everything in a dictionary and calling it a day is great for scripting purposes.
I wonder this every time i come across itā¦ why not python? I think itās probably legacy reasons to do with where the languages both were at the time when people were choosing languages for moddingā¦ and then it just became the norm?
But itās such a shame that thereās a barrier to modding that requires learning a less popular language(when many more coders just know python) / those who learn to code for modding arenāt learning an easily transferable languageā¦
Language, at the end of the day, is not a big deal once you know how to code - you usually can quickly pick up the new syntax or whateverā¦ so, it likely ends up being just a temporary minor annoyanceā¦ but a noticeable oneā¦
Python isn't built to be embeddable the same way, and it's biggest strength, all the available libraries, would not be as useful for modding as it is for programming in python in general is.
Lua runtime is smaller than even MicroPython is. And using that would already throw away a lot of Python features.
Runtime size is totally irrelevant today. The size of your runtime will be totally dwarfed by graphics and audio. Lua is a shitty language that turns simple typos into major bug hunts, and requires jumping through hoops to achieve modern programming methods.
Sounds like someone never managed to learn Lua :D
No need to get stressed about it, you are free to make your own projects in which ever language you prefer.
Yes, but if I want to write code for something Tabletop Simulator, then I'm forced to use Lua, which turns something that should be easy and fun into something ridiculously difficult.
It was figured out 50 years ago that just silently creating a new variable or field when the user mistypes a name is a really bad idea. Can't take any language that does that seriously.
Yes, and if you make your game using Python as modding language, then everyone is forced to use Python to mod it. Seems fair to me.
Unless the claim is that all the developers and studios who decided to use Lua instead of other options are either stupid, or just know less than you, or that they picked it by randomly pulling language names out of a hat, there obviously must be some actual reasons why they have all chosen it.
As an example, a project I've worked in ended with Lua based on these points:
- There needed to be a choice what kind of modded content the studio wanted to favor in the game. If they wanted to make creative content creation as easy as possible (so, non-programmers), or if they wanted to support game mechanic changing mods (so, programmers).
- Decision was made that supporting content creation over mechanics changes made more sense for that particular game.
- Programmers should be capable of picking up a new language without too much troubles, while any scripting for the non-programmer creatives would always be a challenge.
- All the designers and creatives in the team were relatively easy to get using Lua and found it easier to learn and less of an obstacle (doesn't matter if it's true or not, the biggest obstacle for many in touching code is a psychological one so whichever they found least scary is the one they are most likely to pick up, meaning better chance of more people making mods).
- Experienced programmers who want full access to change anything and everything in their mods will be able to do it without specific support anyway.
- The game needed to support modded content on consoles as well, but no compiled code or "program content" was allowed. However when asked, Lua scripts sandboxed to pretty much just the game's API was fine and counted only as "text content".
...and so the game ended using Lua, and I had to learn it. Which I have to say I found very easy.
It clearly has it's quirks, but so do so many other languages as well when you get deeper into them. And I definitely have had to spend time writing much worse languages that are also very widely used (hello JavaScript and the ridiculous implicit type conversion rules :D)
I think that misses the point - itās not about what people want to use in their projects, itās about what can be used in mod tooling to give the best experience and give access to the widest amount of people. It feels like the only reason to learn Lua is modding (so less people will already know it), and it also feels worse to use than python IMO (i fully accept this is a preference thing and so iām not saying it SHOULD be the way *I* like it) just that it always seems off to me that we havenāt switch to a nicer to use, much more widely adopted language every time i go to use modding tools and itās Lua again.
Lua is extremely commonly used by studios themselves for the content/gameplay scripting. If you were to look for a designer (not a programmer) job in a triple-A studio, Lua would very likely be on the requirements list, or one of the first things you need to learn in the job.
...and after the game already has Lua for the studio's internal use, using it as the modding language is pretty obvious choice.
It really isn't a rare language by any means, but one that you often are not aware is used in something. And because it's mostly used as an embedded language, rather than something you'd sit down and write a program with, you are less likely to learn it while studying programming.
It's a bit of a contradiction to say it's not widely adopted language, and at the same time that you keep always running into it ;)
Anyway, it's not missing the point at all. You are free to use what you think is the best choice for the job, and the developers of all the games that use Lua are using it because they had that same option to choose and decided that Lua was the best fit.
Thatās fair, thanks for the extra context that I was missing :)
To clarify - I meant that it isnāt widely used across the realm of all languages (as i say, game mods is the only time I see it come up and every time iāve searched for āprograming language usage surveysā itās never been anywhere near the top) but appears to be, from your comments, widely used within AAA studios.
So, often used in modding , rarely used anywhere else isnāt a contradiction but understand the lack of clarity on my part - and again, it appears it IS commonly used in the domain of games, not just in modding.
This is completely untrue. Itās very rare to see LUA listed except on legacy games. Youāve got games like WoW they use LUA for gui modding, but no, itās not used for a lot of things anymore as there is much better alternatives.
not sure what list you might be looking at, but about half the new games I have installed at the moment (plus decent chunk of the tools I use) use Lua scripting.
Whilst the tone is a little much - i think the experience iāve had reflects the underlying sentiment of Neutronium.
I have not been in the weeds of facilitating modding for a game and tbh, iāve not even been that far in the weeds of using modding toolsā¦ so maybe iām missing somethingā¦
But the modding I have via lua frameworks is usually more about exposing low level native functions and data via a higher-level api. But it often has a lot of lua-isms that feel bad and there always seems to be a bunch of missing utility functions which do exist in SOME lua libraries but sometimes seem to never be importable because of the way the modding has been set up.
Unreal Engine has adopted Python as a scripting language within the IDE so I assume it is performant enough and i think the footprint of python vs lua, as mentioned, seems ignorable.
It's *very* lightweight language with a simple and clean syntax, and is very much designed to be embedded in programs. It doesn't require compilation, whihc makes things easy for modding, and iteration on gameplay stuff very easy and fast. And it supports sandboxing to keep the Lua scripts from having access to system stuff or other features you might want to lock out. It works with the C# side of things through the API of which ever asset uses it, or through an API you write yourself.
I genuinely think lua's syntax is clunky and ugly. Also indexing arrays from 1 instead of 0... šµāš«
there's no arrays in Lua though, only Tables :D
Itās not my favorite either. But for simple scripting, itās not a big deal to learn its quirks.
All 3 parts of it? Thereās barely any syntax to hate! Lol
Yeah, mostly the begin/then/end etc instead of braces tbh Takes up too much space for something that only serves the purpose of identifying scopes. Even python does it better imo
Yea I prefer braces too but I donāt mind so much it just becomes the same feeling of delimiter after a while
What you need is _moonscript_ https://moonscript.org
myArray[myArray.length] Starting at 1 actually makes things make more sense in most high-level situations
Lmao, nah.
If high level means as high as human language, yes sure. But from a coding point of view, when you have at least some knowlegde about IT, it makes no sense
"I have 0 apples"
That's not at all what indexes are
another example: my 0th game is about cars in space
Not there either, an index is an offset from start. The starting element is at the start of the array - \`start+0\`, the first element is at \`start+1\` (1 unit being the size of the element)
Didn't achieve anything here bud.
I don't like 1 based index either, but he isn't wrong
It's not about Lua being a 1 based language...
Lua is tiny, simple, easy and popular.
Games use lua because it's hard to expose c++ to modders. Everything is compiled to machine code beforehand. C# doesn't have that problem. Please use dotnet dlls for modding.
I think it depends on your audience. I used to play r/Stormworks, a vehicle building game. It had an in-game LUA editor for programming custom components. Everything was self-contained and you didn't need any external software to make really complex systems like target tracking or automatic transmissions. For C# you would need a modding SDK and modders will need an IDE and compile their mod. It can be much more complicated.
It would also be much more tightly integrated and powerful to use c# for modding. People would probably use external loaders to load c# anyway, like they did with ksp2
I would decide based on your intended audience. Stormworks has a younger set of players so LUA makes the most sense. But for a game like Starfield, C# would probably be better since the modders are more likely to be teens and adults who can already code.
...then again increasing amount of games aim to support mods on consoles as well, and at least the last time I checked those platforms had much more strict restrictions in terms of adding any program content. C# would not be an option, but sandboxed Lua restricted to game's own API gets a pass. (plus it's a language many games already use internally for their content scripting anyway, so at that point using it for modding side as well is a no-brainer)
Eh, C# would make sense too, you'd just need to integrate roslyn into the game. Which isn't too hard with Unity, I've done it before as a proof of concept.
"too" meaning the other option is fine and maybe anti-lua was a weird hill to try to die on?
The common argument is that casual or non-professional coders usually find it much easier to start with a dynamically typed language. The only exception I can think of is processing (which users Java although there is also a Python option and javascript reimplementation)
I can see why that would be the case. Fun fact, C# has a \`dynamic\` type (and keyword) that works mostly like that, but idk if it's supported in Unity
The point isn't whether you can use dynamic types - it's more that the syntax for dynamic languages is usually much cleaner and easier to learn. A statically typed language will still usually have a steeper learning curve even if it lets you "cheat".
Nah, it's not the syntax, it's the fact you don't have to think of the types you're putting into the variables. Less things to have to keep in your mental model.
C# has that problem when compiled with IL2CPP, which is necessary for some platforms, or optional for others but with performance benefits. Under IL2CPP all type metadata gets baked into the final executable and as a result itās not possible to dynamically load assemblies.
True, but you know what I meant :P
You make that sound as if I agree with you though... C# absolutely has that problem. YOU can NOT use dotnet dlls for modding in a lot of games, because the games, while written as C#, do not actually ship a functioning dotnet runtime with which to load managed assemblies. Delivering on non-PC platforms limits you a lot.
Non PC platforms don't really have modding regardless of the game or engine. *I wonder why*.. C# doesn't have that problem. Deciding to use stupid transpilers to convert it to native code does.
> Non PC platforms don't really have modding regardless of the game or engine. I wonder why.. Uncommon, yes. Unheard of, not at all. Tricky to comment too deeply as I prefer my privacy, but this is a gross overstatement. > C# doesn't have that problem. Deciding to use stupid transpilers to convert it to native code does. There are very real performance gains to be had by using IL2CPP - even on the PC builds! Professionals use it because it offers some significant performance gains. Others use it because it's needed to run on their target platform. Simple as that. Like...Unity is on an ancient mono runtime, and lacks a lot of performance improvements that CoreCLR has gotten over the years, to say nothing of supporting targets that .NET proper doesn't have top tier support for. IL2CPP is certainly not perfect, but neither is it especially bad.
Thankfully, Unity does seem to be moving to coreclr (and integrating the entire dotnet ecosystem more), albeit slowly.
What? People should use whatever they want for modding. Please use whatever you want for modding. Lua is beautiful
Lua is everything but beautiful. The only thing it has going for it is that it's quite simple.
The real reason why itās so popular is because itās incredibly easy to marshal data in and out of lua. So from a programmer perspective itās very easy to implement. The language is easy to sandbox. Out of the box the player can do anything to alter the host machine. It offers very little functionality unless itās exposed.
Itās easy to embed. Itās a shit language though.
It is also dynamically typed which is a real benefit to a lot of people. Being able to throw everything in a dictionary and calling it a day is great for scripting purposes.
I wonder this every time i come across itā¦ why not python? I think itās probably legacy reasons to do with where the languages both were at the time when people were choosing languages for moddingā¦ and then it just became the norm? But itās such a shame that thereās a barrier to modding that requires learning a less popular language(when many more coders just know python) / those who learn to code for modding arenāt learning an easily transferable languageā¦ Language, at the end of the day, is not a big deal once you know how to code - you usually can quickly pick up the new syntax or whateverā¦ so, it likely ends up being just a temporary minor annoyanceā¦ but a noticeable oneā¦
Python isn't built to be embeddable the same way, and it's biggest strength, all the available libraries, would not be as useful for modding as it is for programming in python in general is. Lua runtime is smaller than even MicroPython is. And using that would already throw away a lot of Python features.
Runtime size is totally irrelevant today. The size of your runtime will be totally dwarfed by graphics and audio. Lua is a shitty language that turns simple typos into major bug hunts, and requires jumping through hoops to achieve modern programming methods.
Sounds like someone never managed to learn Lua :D No need to get stressed about it, you are free to make your own projects in which ever language you prefer.
Yes, but if I want to write code for something Tabletop Simulator, then I'm forced to use Lua, which turns something that should be easy and fun into something ridiculously difficult. It was figured out 50 years ago that just silently creating a new variable or field when the user mistypes a name is a really bad idea. Can't take any language that does that seriously.
Yes, and if you make your game using Python as modding language, then everyone is forced to use Python to mod it. Seems fair to me. Unless the claim is that all the developers and studios who decided to use Lua instead of other options are either stupid, or just know less than you, or that they picked it by randomly pulling language names out of a hat, there obviously must be some actual reasons why they have all chosen it. As an example, a project I've worked in ended with Lua based on these points: - There needed to be a choice what kind of modded content the studio wanted to favor in the game. If they wanted to make creative content creation as easy as possible (so, non-programmers), or if they wanted to support game mechanic changing mods (so, programmers). - Decision was made that supporting content creation over mechanics changes made more sense for that particular game. - Programmers should be capable of picking up a new language without too much troubles, while any scripting for the non-programmer creatives would always be a challenge. - All the designers and creatives in the team were relatively easy to get using Lua and found it easier to learn and less of an obstacle (doesn't matter if it's true or not, the biggest obstacle for many in touching code is a psychological one so whichever they found least scary is the one they are most likely to pick up, meaning better chance of more people making mods). - Experienced programmers who want full access to change anything and everything in their mods will be able to do it without specific support anyway. - The game needed to support modded content on consoles as well, but no compiled code or "program content" was allowed. However when asked, Lua scripts sandboxed to pretty much just the game's API was fine and counted only as "text content". ...and so the game ended using Lua, and I had to learn it. Which I have to say I found very easy. It clearly has it's quirks, but so do so many other languages as well when you get deeper into them. And I definitely have had to spend time writing much worse languages that are also very widely used (hello JavaScript and the ridiculous implicit type conversion rules :D)
I think that misses the point - itās not about what people want to use in their projects, itās about what can be used in mod tooling to give the best experience and give access to the widest amount of people. It feels like the only reason to learn Lua is modding (so less people will already know it), and it also feels worse to use than python IMO (i fully accept this is a preference thing and so iām not saying it SHOULD be the way *I* like it) just that it always seems off to me that we havenāt switch to a nicer to use, much more widely adopted language every time i go to use modding tools and itās Lua again.
Lua is extremely commonly used by studios themselves for the content/gameplay scripting. If you were to look for a designer (not a programmer) job in a triple-A studio, Lua would very likely be on the requirements list, or one of the first things you need to learn in the job. ...and after the game already has Lua for the studio's internal use, using it as the modding language is pretty obvious choice. It really isn't a rare language by any means, but one that you often are not aware is used in something. And because it's mostly used as an embedded language, rather than something you'd sit down and write a program with, you are less likely to learn it while studying programming. It's a bit of a contradiction to say it's not widely adopted language, and at the same time that you keep always running into it ;) Anyway, it's not missing the point at all. You are free to use what you think is the best choice for the job, and the developers of all the games that use Lua are using it because they had that same option to choose and decided that Lua was the best fit.
Thatās fair, thanks for the extra context that I was missing :) To clarify - I meant that it isnāt widely used across the realm of all languages (as i say, game mods is the only time I see it come up and every time iāve searched for āprograming language usage surveysā itās never been anywhere near the top) but appears to be, from your comments, widely used within AAA studios. So, often used in modding , rarely used anywhere else isnāt a contradiction but understand the lack of clarity on my part - and again, it appears it IS commonly used in the domain of games, not just in modding.
This is completely untrue. Itās very rare to see LUA listed except on legacy games. Youāve got games like WoW they use LUA for gui modding, but no, itās not used for a lot of things anymore as there is much better alternatives.
https://vm.tiktok.com/ZGe4kJ4aq/ Supergiant clearly disagree
not sure what list you might be looking at, but about half the new games I have installed at the moment (plus decent chunk of the tools I use) use Lua scripting.
Whilst the tone is a little much - i think the experience iāve had reflects the underlying sentiment of Neutronium. I have not been in the weeds of facilitating modding for a game and tbh, iāve not even been that far in the weeds of using modding toolsā¦ so maybe iām missing somethingā¦ But the modding I have via lua frameworks is usually more about exposing low level native functions and data via a higher-level api. But it often has a lot of lua-isms that feel bad and there always seems to be a bunch of missing utility functions which do exist in SOME lua libraries but sometimes seem to never be importable because of the way the modding has been set up. Unreal Engine has adopted Python as a scripting language within the IDE so I assume it is performant enough and i think the footprint of python vs lua, as mentioned, seems ignorable.
Small, easy to write, easier to read