Move GUI interfaces from C++ to Lua

Things that we aren't going to implement
danbopes
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Move GUI interfaces from C++ to Lua

Post by danbopes »

TL;DR
Request: Move all GUI elements from C++ to Lua to improve extensibility for modders.
What?
I’m requesting that Factorio’s GUI elements, currently implemented in C++, be fully migrated to Lua. This shift would allow mods to directly extend, modify, and integrate with the GUI elements instead of just attaching additional components via relative_gui_position anchor points.
Why?
The current C++-based GUI system is restrictive for modders because it doesn’t allow direct modifications. As a result, the only feasible way to extend the GUI is by anchoring new elements, which lacks flexibility and can feel disconnected. By moving all GUI elements to Lua, Factorio would enable more cohesive integrations—similar to how World of Warcraft’s Lua-based GUI allows mods to extend and modify any element directly, improving the user experience.

This change would make the game’s GUI system inherently more extensible and easier to work with. While there might be some overhead in shifting to Lua, GUI elements are generally less resource-intensive compared to other performance-sensitive areas, like logistics, so this impact should be manageable.
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 251
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by BraveCaperCat »

I agree with this change. +1! +1 for everyone! +2 if I can do it!
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2983
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by boskid »

Uh, this is one of the broadest scope suggestion i have ever seen and i can already tell you noone is going to do this. Guis inherently have to not be part of game state as multiple things in gui are part of latency hiding and a lot of it needs to send input actions, generate tooltips based on cursor position and use interface settings that are not part of game state. If this would ever be done, it would have to be a separate lua state without access to game state or with a read only access to game state, so: all lua objects would have to be revisited if they mutate game state, a lot of non game state data would have to be exposed, a lot of input actions send functions would have to be exposed, latency hiding woukd have to be considered. I am not seeing any sane way of doing this.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by Rseding91 »

I’m comfortable saying this will never happen.
If you want to get ahold of me I'm almost always on Discord.
danbopes
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by danbopes »

boskid wrote: Mon Nov 11, 2024 12:32 pm Uh, this is one of the broadest scope suggestion i have ever seen and i can already tell you noone is going to do this. Guis inherently have to not be part of game state as multiple things in gui are part of latency hiding and a lot of it needs to send input actions, generate tooltips based on cursor position and use interface settings that are not part of game state. If this would ever be done, it would have to be a separate lua state without access to game state or with a read only access to game state, so: all lua objects would have to be revisited if they mutate game state, a lot of non game state data would have to be exposed, a lot of input actions send functions would have to be exposed, latency hiding woukd have to be considered. I am not seeing any sane way of doing this.
Thanks for the thorough explanation! I completely understand now why moving everything to Lua would be difficult given the technical hurdles you mentioned.

That said, I do want to emphasize the limitations this puts on modding. As it says in the Untitled's GUI Guide:
It is a somewhat frequent occurrence to want a mod to add to or modify an existing base-game interface for some reason... If that occurred to you, I have some bad news: You can't.
This leads modders to the "Nuclear Option": completely replacing a vanilla interface just to add something small, like a button. It’s a heavy-handed workaround, but sometimes it’s the only option if we want full control.

To avoid pushing modders to this "nuclear" route, could a gradual shift to Lua work, where certain non-critical or informational panels are transitioned over time? This approach could give us a bit more freedom to extend and customize without needing a full-scale replacement.

Thanks again for considering it, and I’d love to hear any thoughts on whether a gradual transition could be feasible.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by curiosity »

danbopes wrote: Mon Nov 11, 2024 1:35 pm This leads modders to the "Nuclear Option": completely replacing a vanilla interface just to add something small, like a button.
That's why anchored frames exist.
danbopes
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by danbopes »

curiosity wrote: Mon Nov 11, 2024 4:50 pm
danbopes wrote: Mon Nov 11, 2024 1:35 pm This leads modders to the "Nuclear Option": completely replacing a vanilla interface just to add something small, like a button.
That's why anchored frames exist.
Anchored frames are a kludgy workaround. The frame appears disjointed, and even if styled right, still has to appear outside the main GUI to function (Whereas a GUI that's built in LUA could be extended with ease)
danbopes
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by danbopes »

Rseding91 wrote: Mon Nov 11, 2024 1:22 pm I’m comfortable saying this will never happen.
I understand this was quite a broad request, but the implications if this could be implemented would be enormous. Coming from World of Warcraft, and trying to dive into Factorio lua, I just straight up threw my hands in the air and said F this to the workarounds I have to make just to extend a simple circuit condition. I just ask that the devs take a look at the approach to the guis and build them with an extension developer's frame of mind.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by curiosity »

danbopes wrote: Mon Nov 11, 2024 5:04 pm Anchored frames are a kludgy workaround. The frame appears disjointed, and even if styled right, still has to appear outside the main GUI to function (Whereas a GUI that's built in LUA could be extended with ease)
Yes, it is, but at least it's something. The devs are extremely stingy with anything that touches UI, it's a wonder we've got as much as we do. If it was up to me, I'd have already implemented client mods.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by Rseding91 »

danbopes wrote: Mon Nov 11, 2024 5:09 pm I just ask that the devs take a look at the approach to the guis and build them with an extension developer's frame of mind.
We're over 10 years into Factorio at this point and GUI accounts for 12.5% of the total code by size. That's currently 119'149 lines of GUI code spread across 1'161 files. Measurably 0% of the GUI code is setup to handle mods poking at it or making changes to it. It's all non-game-state with mods being almost 100% game-state.

It's never going to happen. We are not going to delete and re-write the entire GUI system after 10 years of work at this point in development.

curiosity wrote: Mon Nov 11, 2024 5:14 pm If it was up to me, I'd have already implemented client mods.
You are of course welcome to write your own version of Factorio and implement your version of the game however you see fit.
If you want to get ahold of me I'm almost always on Discord.
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 251
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by BraveCaperCat »

Rseding91 wrote: Mon Nov 11, 2024 5:29 pm
curiosity wrote: Mon Nov 11, 2024 5:14 pm If it was up to me, I'd have already implemented client mods.
You are of course welcome to write your own version of Factorio and implement your version of the game however you see fit.
I would think that would be against some ToS regulation I haven't seen yet, or against copyright.
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Move GUI interfaces from C++ to Lua

Post by curiosity »

Rseding91 wrote: Mon Nov 11, 2024 5:29 pm You are of course welcome to write your own version of Factorio and implement your version of the game however you see fit.
Don't you worry, it's not the lack of your approval that stops me, but all the extra work.
BraveCaperCat wrote: Mon Nov 11, 2024 9:11 pm I would think that would be against some ToS regulation I haven't seen yet, or against copyright.
It's explicitly covered by ToS. Wube obtains the rights to any derivative works.
Post Reply

Return to “Won't implement”