Seeking help with modding with circuit signals
Posted: Mon Apr 14, 2025 7:55 pm
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.
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.