Seeking help with modding with circuit signals

Place to get help with not working mods / modding interface.
CitizenAbacus
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Apr 14, 2025 7:32 pm
Contact:

Seeking help with modding with circuit signals

Post by CitizenAbacus »

Hello, all. Thanks in advance for any help.

I'm taking my first stab at modding Factorio, trying to make a mod that will cause turrets to emit a signal when they are in combat. The current state of the mod can be seen here. I did the base and GUI tutorial, and then pulled some ideas from the SearchlightAssault mod.

To sum up how I'm trying to go about this at this point:
1. Add a checkbox to turret GUI
2. Capture the on_click event for that checkbox
3. When clicked find turrets near where the player is looking, which can't possibly be the right way to do that, and find one that matches the unit_number of the turret whose menu I know is open
4. Register that turret's entity with an array in storage of turrets whose firing state I want to know about
5. TODO: unregister the entity when unchecking the box

Then about twice a second I look through that array for any that are shooting. I managed to get them to print a message, but I can't figure out how to make it emit a circuit signal. Looking at the SearchlightAssault mod from which I stole a good bit of what I have it looks like there might be a hidden combinator in there, but I think that's for the custom GUI. I can't where in the Lua code it's actually emitting the signal.

And, of course, if you happen to think anything else about how I'm doing this seems wrong or sub optimal I'm open to criticism on that. I'm definitely going to have to revisit how I register with the array in storage, for example, because the way I have it now won't work with a blueprinted turret.
Natha
Filter Inserter
Filter Inserter
Posts: 259
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Seeking help with modding with circuit signals

Post by Natha »

You can stick custom GUIs to entity GUIs. Then just add a checkbox with tags, whose contents are the unit numer. Listen to the on_checkbox_checked event and read the tags, then you have your number
CitizenAbacus
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Apr 14, 2025 7:32 pm
Contact:

Re: Seeking help with modding with circuit signals

Post by CitizenAbacus »

I think that's what I did in this method, right? I would just need to change the checkbox from an on_gui_clicked later on in the file to an on_checkbox_checked, which makes sense as an improvement on what I'm doing so far. Will that be captured when the entity is copied? Like if I blueprint the entity will the entity, on creation, know that it is clicked and fire the on_checkbox_checked event?
Natha
Filter Inserter
Filter Inserter
Posts: 259
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Seeking help with modding with circuit signals

Post by Natha »

No, there is no internal connection between that gui and that entity
Post Reply

Return to “Modding help”