Cataclysm-dda: [Suggestion]LUA callbacks

Created on 31 Jan 2017  路  19Comments  路  Source: CleverRaven/Cataclysm-DDA

LUA callback when activating/deactivating bionics and mutations. This will enable to make more advanced bionics and mutations.

<Suggestion / Discussion>

Most helpful comment

On Feb 2, 2017 11:45 AM, "Justin" notifications@github.com wrote:

Lua would probably be used more if it were better fleshed out.

Initial LUA support was added by commit
88dc3fd56939390c73d3f536bb67d8c66ade53c4 over THREE YEARS AGO. In that
three years the game has had massive extension in nearly all areas, but a
compelling use case for LUA support has yet to surface. Proponents have
continued to insist it will be massively useful, but NO ONE IS USING IT.
So for three years we've merged extensions to it, kept data bindings up to
date, and made our build process more difficult than it had to be because
LUAs packaging is insane, with literally nothing to show for it. Let me
repeat that, LITERALLY NOTHING. The proof of concept type code present in
e.g. faster zombies could be rewritten in c++ in minutes, or replaced with
a parameterized json mechanism with similar functionality in part of an
evening. Meanwhile we can drop thousands of lines of rather complex data
binding definition and code, trim some gnarly code out of the Makefile and
other project files, and drop a library dependency that has made building
on Windows in particular a pain in the ass.

After three years and thousands and thousands of lines of code, I'm calling
it, LUA support is a total failure, and I intend to remove it as soon as is
convinient. Please don't open any PRs or issues about LUA, because it's
dead.

I've tried pushing the idea of moving bits of core logic to lua (iuse,
special attacks, generally non performance critical pieces of logic) but
that has been shut down every time I suggest it.

LUA support has been provisional for its entire existence, doubling down by
embedding it further in the game with literally zero evidence that there is
real interest in using it has never been an option.
If someone had simply written a significant new feature in LUA at any point
in the past three years, we wouldn't be having this discussion, but no,
dispite ~5 core contributors being heavily invested enough in it to spend
significant time building infrastructure for it, none of them or anyone
else has shown any interest in developing actual features in the language
once their infrastructure was merged.
Frankly I now consider its provisional addition three years ago to have
been a mistake, YAGNI is in full force, speculatively adding infrastructure
that might be used some time later is never a good idea, build
infrastructure to support features you need, no more.

All 19 comments

Is anyone even using the Lua bindings? As far as I can tell the whole Lua thing has been a massive waste of time.

Stats Through Skills uses it. I recall one of the less popular mods also using it - Cataclysm++?

I wanted to add a sci-fi mod which would use it (for psionic powers), but I'll refrain if you want to axe Lua - if it was just my mod, I could implement that in C++.

That's what keeps happening, it would be way easier to just expose apis that let mods use json to adjust things than to continue supporting Lua, for the existing uses at least. I'd be perfectly happy to keep it around if it were actually needed, but AFAIK it's not being used for anything that's easier to do with Lua. I'll take a look at cataclysm++ and get an idea of what it's using it for.

I would love to see LUA mapgen be used more since it can be used to create more randomized and alive feeling structures than JSON.

How does a mod implement customized iuse functions and iexamine functions without lua bindings?

@kevingranade & @Coolthulhu , The cataclysm++ mod does not use lua, its pure json files.

Firn and I discussed using LUA to create a photography mod.

Lua would probably be used more if it were better fleshed out. I've tried pushing the idea of moving bits of core logic to lua (iuse, special attacks, generally non performance critical pieces of logic) but that has been shut down every time I suggest it. By pushing more of our logic to lua, we find the holes in the api that would let us expand its functionality, which would make it easier for modder to create more sophisticated mods without needing to learn C++.

Problem with Lua is that it isn't a hard dependency, meaning we can't move core game logic to it.

And that is why we don't see more mods using it. If we want to see more mods using Lua, we need to mainline it, and move (some) core game logic to it. This would enable modders to create mods that core game functionality without needs to get into the source code. Mods that currently require the modder to release their own build of the game could then slowly be worked into lua mods. It would be easier for us to mainline mods that alter gameplay logic, since they wouldn't need to alter the source code to achieve the functionality they're looking for.

@Marberguson Do you intend to implement a mod that does this?


Most of the below is OT in relation to OP.

@macrosblackd:

This would enable modders to create mods that core game functionality without needs to get into the source code.

Lua is a programming language. The need to "get into the source code" would not disappear if a modder decided to use it.

@kevingranade:

That's what keeps happening, it would be way easier to just expose apis that let mods use json to adjust things than to continue supporting Lua, for the existing uses at least.

Tend to agree on "current uses" part. However, the promise of Lua is providing non-implemented functionality.

Some current non-critical parts _could_ be off-loaded to Lua. Games that come with "handheld game system" seem a good example. Or controlling an RC car (with IED attached)?..

I've been thinking about something like this, but TBH there's always more important bugs.

On-topic: tried slapping together an example, a naive lua_callback() seems insufficient - need to pass the bionic to Lua, and possibly not just the name.

Otherwise, the Lua mod would have to sift through all the character's bionics, EDIT: and match them to bionics handled by the mod.

EDIT2: Passing a bionic would allow the mod to forego "What is it that changed?", but would still need checking "Am I responsible for this?" - demonstrating clearly the need to "get into the source code".


EDIT3: To clarify, I don't intend to make a Lua-using bionics mod. This was just a "How hard can it be?".

On Feb 2, 2017 11:45 AM, "Justin" notifications@github.com wrote:

Lua would probably be used more if it were better fleshed out.

Initial LUA support was added by commit
88dc3fd56939390c73d3f536bb67d8c66ade53c4 over THREE YEARS AGO. In that
three years the game has had massive extension in nearly all areas, but a
compelling use case for LUA support has yet to surface. Proponents have
continued to insist it will be massively useful, but NO ONE IS USING IT.
So for three years we've merged extensions to it, kept data bindings up to
date, and made our build process more difficult than it had to be because
LUAs packaging is insane, with literally nothing to show for it. Let me
repeat that, LITERALLY NOTHING. The proof of concept type code present in
e.g. faster zombies could be rewritten in c++ in minutes, or replaced with
a parameterized json mechanism with similar functionality in part of an
evening. Meanwhile we can drop thousands of lines of rather complex data
binding definition and code, trim some gnarly code out of the Makefile and
other project files, and drop a library dependency that has made building
on Windows in particular a pain in the ass.

After three years and thousands and thousands of lines of code, I'm calling
it, LUA support is a total failure, and I intend to remove it as soon as is
convinient. Please don't open any PRs or issues about LUA, because it's
dead.

I've tried pushing the idea of moving bits of core logic to lua (iuse,
special attacks, generally non performance critical pieces of logic) but
that has been shut down every time I suggest it.

LUA support has been provisional for its entire existence, doubling down by
embedding it further in the game with literally zero evidence that there is
real interest in using it has never been an option.
If someone had simply written a significant new feature in LUA at any point
in the past three years, we wouldn't be having this discussion, but no,
dispite ~5 core contributors being heavily invested enough in it to spend
significant time building infrastructure for it, none of them or anyone
else has shown any interest in developing actual features in the language
once their infrastructure was merged.
Frankly I now consider its provisional addition three years ago to have
been a mistake, YAGNI is in full force, speculatively adding infrastructure
that might be used some time later is never a good idea, build
infrastructure to support features you need, no more.

Made a thread: http://smf.cataclysmdda.com/index.php?topic=14231

Judging from what was said before, we're axing Lua after 0.D comes out, correct?

What about Stats through Skills, doesn't that use Lua? It is on its fifth
or so iteration, isn't it? And Slow Zombies and Tough Zombies and Zombie
Nightvision use it too, I think.

Rewritting them as C++ would be less effort than keeping that Lua interface around.

Made a thread: http://smf.cataclysmdda.com/index.php?topic=14231

Good call, someone coming out of the woodwork stating, "I use LUA extensively in my huge mod you've never heard of" is pretty much the only thing that can save it now.

Judging from what was said before, we're axing Lua after 0.D comes out, correct?

That's the plan, yes.

Rewritting them as C++ would be less effort than keeping that Lua interface around.

So much this.

Linking to #21743 and #21744.

Was this page helpful?
0 / 5 - 0 ratings