diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index c27e3b4..e30b87f 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -426,7 +426,7 @@ local function handle_research_queue(combinator) end end -local function handle_valve_value(combinator) +local function handle_valve_value(entity, combinator) local combinator_slot = combinator.get_slot(1) if not (combinator_slot or (combinator_slot.value and combinator_slot.value.name and combinator_slot.value.name == 'signal-SA')) then @@ -436,8 +436,24 @@ local function handle_valve_value(combinator) local combinator_slot_value = combinator_slot.get_slot(1).min or 0 - if (combinator_slot_value >= 0 and combinator_slot_value < 101) then + if (combinator_slot_value >= -1 and combinator_slot_value < 101) then -- every item in front of it? + local v = entity.surface.find_entities_filtered{type='valve', position=entity.position, radius=1} + + if not (v or #v == 0) then + return + end + + for _, valve in pairs(v) do + if valve.valve_threshold_override then + if combinator_slot_value == -1 then + valve.valve_threshold_override = nil + + else + valve.valve_threshold_override = combinator_slot_value / 100 + end + end + end end end @@ -459,7 +475,7 @@ script.on_nth_tick(10, function(_) if combinator and combinator.sections_count then if combinator.sections_count > 0 then handle_research_queue(combinator) - handle_valve_value(combinator) + handle_valve_value(entity, combinator) else combinator.add_section()