Hey all!
I want to make an entity in my mod that has two input wires and two output wires and does some logic on them in the middle. I've been poking my head around the source code of other mods, tutorials and the modding API but I can't seem to get this to work. Whenever I set the type of the data to "arithmetic-combinator" the built-in arithmetic combinator UI and code takes over the entity. When I set the type to "constant-combinator" I can no longer define input and output wire locations.
What I'd like to do is be able to define my own UI and output based on inputted wires (two input wires are necessary).
Any help is appreciated,
Griffork.
How to make a custom arithmetic/decider combinator?
Re: How to make a custom arithmetic/decider combinator?
You need to use 2 entities, one for input and one for output. Listen for the built_entity events and create a second entity when your primary entity is built.
Re: How to make a custom arithmetic/decider combinator?
So is there any way to override the built-in UI for a custom arithmetic combinator?
I see https://lua-api.factorio.com/latest/eve ... tem_opened, but when setting "can_be_mod_opened=1" in either the entity or item definition to data.raw, nothing seems to happen later on
I can't use a custom type when populating the data.raw table, and it seems that whatever happens, I can't override the game attempting to process the circuit network.
i.e. it seems that the built-in on_tick() for the arithmetic combinator looks at the type, rather than the name of the entity
I see https://lua-api.factorio.com/latest/eve ... tem_opened, but when setting "can_be_mod_opened=1" in either the entity or item definition to data.raw, nothing seems to happen later on
I can't use a custom type when populating the data.raw table, and it seems that whatever happens, I can't override the game attempting to process the circuit network.
i.e. it seems that the built-in on_tick() for the arithmetic combinator looks at the type, rather than the name of the entity
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to make a custom arithmetic/decider combinator?
Roughtly something like:cyfrov wrote:So is there any way to override the built-in UI for a custom arithmetic combinator?
Code: Select all
script.on_event(defines.events.on_gui_opened, function(event)
local player = game.players[event.player_index]
if player.opened and (player.opened.name == 'yourcombinator') do
player.opened = nil
local gui = player.center.add{'type=frame'} --etcpp, create your custom gui
player.opened = gui
end end)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Inserter
- Posts: 26
- Joined: Tue Jun 26, 2018 11:01 am
- Contact:
Re: How to make a custom arithmetic/decider combinator?
I don't recommend modify data.raw table, it's better to make your entity apart from vanilla ones, you'll have much more freedom with the definitions
Vanilla combinators have too much code written in C for performance reasons, make combinator logic in LUA is not recommended unless it's really critical for your mod and you don't need to update information every tick
I already made a custom combinator, "https://mods.factorio.com/mod/CW-power-combinator". You can look at its code, I almost made the main entity from scratch and used invisible vanilla combinators for internal processing
You can ask additional questions about my mod at any time (reading other people's code is not easy at all)
Vanilla combinators have too much code written in C for performance reasons, make combinator logic in LUA is not recommended unless it's really critical for your mod and you don't need to update information every tick
I already made a custom combinator, "https://mods.factorio.com/mod/CW-power-combinator". You can look at its code, I almost made the main entity from scratch and used invisible vanilla combinators for internal processing
You can ask additional questions about my mod at any time (reading other people's code is not easy at all)