Help with Gui for custom entities
Posted: Tue Dec 03, 2024 11:15 pm
This is my first foray into factorio modding, and so after doing the tutorial on the wiki and reading over the docs, I figured I'd start with a light feature I always wanted, an electric heater. I've gotten 90% of the way there, creating a prototype based on the heating tower that swaps out the burner energy source for an electric one, and in the game I can successfully craft and place the new building and it functions as intended.
The issue however comes from the GUI, or more accurately the lack thereof. When clicking on the GUI nothing comes up, which is a bit of a problem given that the GUI has the all-important circuit interface that's would be really helpful so you can read the temperature of the heater and turn it off when it's not needed. After much poking around I'm pretty sure the issue is caused by the runtime class LuaReactorControlBehaviour, which has an option to read the fuel contents, which don't exist because the heater has an electric power source.
Sure enough, when I changed my modded building back to a burner energy source it started working again and you could access the GUI. Interestingly it also fixed the animations (before the heater was permanently stuck in the "active" animation even when unpowered), so I'm guessing the two are related. I figure I probably need to make a modified version of LuaReactorControlBehaviour to get this to work the way I want but I have no idea how to find the original or how I would even go about implementing it as it's not a prototype. Any help on figuring out where and how to create lua classes for these GUI elements for modded entities would be greatly appreciated.
The issue however comes from the GUI, or more accurately the lack thereof. When clicking on the GUI nothing comes up, which is a bit of a problem given that the GUI has the all-important circuit interface that's would be really helpful so you can read the temperature of the heater and turn it off when it's not needed. After much poking around I'm pretty sure the issue is caused by the runtime class LuaReactorControlBehaviour, which has an option to read the fuel contents, which don't exist because the heater has an electric power source.
Sure enough, when I changed my modded building back to a burner energy source it started working again and you could access the GUI. Interestingly it also fixed the animations (before the heater was permanently stuck in the "active" animation even when unpowered), so I'm guessing the two are related. I figure I probably need to make a modified version of LuaReactorControlBehaviour to get this to work the way I want but I have no idea how to find the original or how I would even go about implementing it as it's not a prototype. Any help on figuring out where and how to create lua classes for these GUI elements for modded entities would be greatly appreciated.