[2.0] How to script constant combinators using the new `LuaLogisticSection`

Place to get help with not working mods / modding interface.
User avatar
LCStark
Fast Inserter
Fast Inserter
Posts: 200
Joined: Thu Jan 28, 2021 5:04 pm
Contact:

[2.0] How to script constant combinators using the new `LuaLogisticSection`

Post by LCStark »

I've been trying to understand the new combinator system for the past few hours and I feel like I'm missing something simple here. In 1.1, I've used a modified constant combinator (which players couldn't open and change the signal value), and the script updated it with

Code: Select all

set_signal(1, { signal = { type = "item", name = "powerSat" }, count = count })
when I wanted to change the value.

Now constant combinators use the logistic groups and I can't seem to get them to work. When I place a new combinator, I set that signal to 0:

Code: Select all

local behaviour = _entity.get_or_create_control_behavior()
if (behaviour.sections_count == 0) then behaviour.add_section() end
local section = behaviour.get_section(1)
section.set_slot(1, { value = { name = "powerSat", type="item" }, min = 0, max = 0 })
And with the `/editor` I can check the combinator and see that it works correctly adding my signal with value 0. But when I need to update it, I get the slot and change its min and max values:

Code: Select all

local behaviour = v.get_or_create_control_behavior()
local section = behaviour.get_section(1)
local slot = section.get_slot(1)
slot.min = count
slot.max = count
section.set_slot(1, slot)
And I get the error "Can't specify non zero request with non trivial item filter condition" on the `section.set_slot(1, slot)` line.

Is this the right way to do it, or did I miss some other way of setting constant combinator values via script?
firebladed3
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jun 30, 2017 5:22 pm
Contact:

Re: [2.0] How to script constant combinators using the new `LuaLogisticSection`

Post by firebladed3 »

its mentioned somewhere on here, i forget where, that there is a issue? with the quality setting

you have to set quality to avoid that error
e.g

Code: Select all

			local logisticfilter = {}
			local signalfilter = {}		
			
			signalfilter.type = "item"
			signalfilter.name = k
			signalfilter.quality = "normal" 
			signalfilter.comparator = nil	
			
			logisticfilter.value = signalfilter
			logisticfilter.min = n
			logisticfilter.max = n
			
			outsection.set_slot(i,logisticfilter)

or thats at least what worked for me setting constant combinator outputs, when i got that error


Edit: Found the post that lead to that solution
User avatar
LCStark
Fast Inserter
Fast Inserter
Posts: 200
Joined: Thu Jan 28, 2021 5:04 pm
Contact:

Re: [2.0] How to script constant combinators using the new `LuaLogisticSection`

Post by LCStark »

Thanks firebladed3, that did it! I'd expect "any" quality to be the default option for constant combinators, good to know that it is a bug that will be fixed. And after staring at that thing for hours I got so focused I didn't even think to try assigning quality manually. Now since it works I can get on to making it work good. Thanks again!
Post Reply

Return to “Modding help”