# The State of LUA in DDA

**URL:** https://discourse.cataclysmdda.org/t/the-state-of-lua-in-dda/15291
**Category:** The Toolbox
**Created:** [April 19, 2018, 1:44am UTC](https://discourse.cataclysmdda.org/t/the-state-of-lua-in-dda/15291 "2018-04-19T01:44:28Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)
#### Post date: [April 19, 2018, 11:41pm UTC](https://discourse.cataclysmdda.org/t/the-state-of-lua-in-dda/15291/5 "2018-04-19T23:41:00Z")

</div>

> [@GrumpyProgrammer](#):
>
> From what I’ve seen (and, admittedly, I’ve really only glanced over things), Lua is not being used in it’s best suitably in DDA right now. The best use-case I can see for Lua is in dialog trees, quests, and NPC interaction which require rapid prototyping and evolution (even a few seconds to recompile after every change adds up), but there doesn’t seem to be much support for Lua in this area.

I agree with these statements, and they outline the core weakness of our LUA infrastructure. Instead of saying, “what is LUA good at?” then adding support for those things, the approach was “LUA is used for scripting in games, so let’s add it”. As a result, you can do a bunch of essentially random things in LUA, but there is no coherent or comprehensive support for doing things that LUA is good at in LUA. Even worse, since there’s no plan or goal to outline what good LUA support should look like, the only solution to “fixing” LUA integration is externalizing more and more game state, which has a terrible cost/benefit ratio.

[This](https://discourse.cataclysmdda.org/t/lua-may-be-getting-axed-how-many-people-care/13488/38) is probably the most complete rationale that I’ve posted, and in broad strokes it’s the same as what you pointed out, there’s nothing wrong with LUA, but the way we’re using it is deeply dysfunctional.

So, to address your question:

> [@GrumpyProgrammer](#):
>
> If I am understanding this correctly, then has @kevin.granade specified what exactly he wants to see in Lua-based mods to make the maintenance requirement worth it?

I have not, specifically because I don’t know what working LUA integration would even look like. Just piling more mods that use LUA on isn’t going to fix the fundamental problem:

> [@Lua may be getting axed, how many people care?](https://discourse.cataclysmdda.org/t/lua-may-be-getting-axed-how-many-people-care/13488/38):
>
> The lua bindings themselves are 24,000 lines of C++.
> 
> On the other hand, we have what you see listed in this thread, an extremely meagre list of features, that in most cases would have been quicker to develop in C++, totaling something like a few dozen hours worth of development. There’s something like 2,000 lines of LUA that have been written for this project.
> 
> This ratio just. does. not. make. sense.

In short, the current LUA support does _not_ make it faster to add things to the game, _it doesn’t work_. Every line of LUA in the game is backed by 10+ lines of C++ infrastructure, that ratio is unsustainable.

What I would need to see for LUA integration to remain is a convincing argument/plan for:  
What LUA is good/essential for.  
What bindings are required to enable that functionality.  
An outline describing how the amount of c++ and binding code required to make that happen is dwarfed by the increased productivity of using LUA for that task instead of coding it in c++ or json directly.  
An argument outlining why JSON plus a judicious amount of C++ can’t do the same thing.

Even with those arguments successfully made, I would still be axing _most_ of the LUA bindings, specifically the ones that are not needed for the use cases identified in the plan. Even if LUA has a good use, we still need to trim the fat, because right now there’s an absurd amount of game state exposed to LUA, and the vast majority of it is unused.

Side note, I’ve become really sceptical that embedding LUA is as productive as people keep claiming. I keep running across things like [this](https://engineering.riotgames.com/news/taxonomy-tech-debt) where we find out that LoL heavily uses LUA (oh hey they’re super successful, so it must be working), only to have it clarified that it’s now considered 100% tech debt, and that it was a _mistake_ to use it, and that they have a large and very expensive proposal to root LUA out because it’s causing major problems.

---

_[View the full topic](https://discourse.cataclysmdda.org/t/the-state-of-lua-in-dda/15291)._
