Custom ArithmeticCombinator

Place to get help with not working mods / modding interface.
Post Reply
juggernaut
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Jul 20, 2016 7:41 am
Contact:

Custom ArithmeticCombinator

Post by juggernaut »

This is my first mod. I want to create my combinator with new logic, it must have a signal input and an output. I took the arithmetic combinator as a prototype.
I figured out how to read the signal that comes to the combinator, but didn't figure out how to output it.
I call

Code: Select all

entity.get_or_create_control_behavior ()
and I get the LuaArithmeticCombinatorControlBehavior object. He has a field parameters, but how does it work? How can I tell the combinator to output a certain signal to its outputs? I also did not understand with ArithmeticCombinatorParameters, since the amount of signal cannot be specified there.
Sorry for my googletranslate :D

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 318
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: Custom ArithmeticCombinator

Post by Stringweasel »

Best would be to download a mod that does something similar to what you want to do, and then see what they did. Maybe something like this? https://mods.factorio.com/mod/UsefulCombinators

And for reference, this is how I've managed to change the output of a constant combinator in one of my mods. Should be very similar for other combinators.

Code: Select all

local entity = game.surfaces.nauvis.find_entity("constant-combinator", {85.5, -72.5}) 
local control = entity.get_or_create_control_behavior() 
control.enabled = true -- This turned on the constant combinator (was previously off)
Good luck! :)
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 318
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: Custom ArithmeticCombinator

Post by Stringweasel »

Realized my previous post wasn't very helpful. Looking at other mods like this one it seems like it's not easy modifying other combinators to output what you want it to output. It looks like you would need to put your output on a invisible constant combinator.
https://mods.factorio.com/mod/stack-combinator
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: Custom ArithmeticCombinator

Post by torne »

I don't think you can set the output if you're using the arithmetic combinator as the prototype. That already has a behaviour associated with it: it does arithmetic, according to the settings in its control behaviour.

If you want to output signals of your choice you would need to use a constant combinator prototype. Depending what you're trying to do you might need to make a composite entity, with more than one actual game object with different prototypes; e.g. if you need to read input signals.

juggernaut
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Jul 20, 2016 7:41 am
Contact:

Re: Custom ArithmeticCombinator

Post by juggernaut »

Thanks for the tip. I seem to have figured it out with this, but 1 more question has appeared.
I copied the prototype from ArithmeticCombinator and changed its name. But when you click on the object, the ArithmeticCombinator menu opens anyway. How can we get out of this?
1) I know that it is possible in principle to indicate that the menu of the object does not open (but I do not need this).
2) If I need to open my custom menu, then I must specify player.opened = my_window, otherwise the ArithmeticCombinator menu will open.
Am I doing it right or how should it be right?

Post Reply

Return to “Modding help”