From e948c21c2c15d0eb16664267961eb5e682938e7f Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Thu, 31 Aug 2017 23:49:54 -0700 Subject: [PATCH 1/2] Improve max-combinator This makes the max-combinator not filter the signals if there is no filter set. Also, the magnitude of the input signal is emitted to the 'output-signal' signal. --- UsefulCombinators_0.4.0/control.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/UsefulCombinators_0.4.0/control.lua b/UsefulCombinators_0.4.0/control.lua index 3b4931c..ab0af90 100644 --- a/UsefulCombinators_0.4.0/control.lua +++ b/UsefulCombinators_0.4.0/control.lua @@ -366,23 +366,35 @@ classes["max-combinator"] = { local signals = get_signals(control) local signal = {type = "virtual"} local count = -math.huge - for k,v in pairs(signals) do - count = math.max(count, v.count) - if count == v.count then - signal = v.signal + if signals then + for k,v in pairs(signals) do + if v.signal.name ~= "output-signal" then + count = math.max(count, v.count) + if count == v.count then + signal = v.signal + end + end end end - count = 1 + local ncount = 1 if count == -math.huge then + ncount = 0 count = 0 end + local f1 = false for _,i in pairs(params) do if i.signal.name then + f1 = true if signal.name == i.signal.name then - table.insert(slots, {signal = signal, count = count, index = 1}) + table.insert(slots, {signal = signal, count = ncount, index = 1}) + table.insert(slots, {signal = {type="virtual", name="output-signal"}, count = count, index = 2}) end end end + if not f1 then + table.insert(slots, {signal = signal, count = ncount, index = 1}) + table.insert(slots, {signal = {type="virtual", name="output-signal"}, count = count, index = 2}) + end control.parameters = { parameters = slots } @@ -2187,4 +2199,4 @@ script.on_event(defines.events.on_tick, tick) script.on_event(defines.events.on_gui_click, on_click_ok) --script.on_event(defines.events.on_entity_settings_pasted, on_paste) script.on_event("uc-edit", on_key) -script.on_configuration_changed(configuration_changed) \ No newline at end of file +script.on_configuration_changed(configuration_changed) From 7f770b07f003d9035649bf1e725218a9c2a6e91a Mon Sep 17 00:00:00 2001 From: Logan Perkins Date: Thu, 31 Aug 2017 23:51:17 -0700 Subject: [PATCH 2/2] update max-combinator signal count to 2 This change is required for outputting the magnitude of the maximum input signal to the `output-signal` signal. --- UsefulCombinators_0.4.0/prototypes/entity/entities.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UsefulCombinators_0.4.0/prototypes/entity/entities.lua b/UsefulCombinators_0.4.0/prototypes/entity/entities.lua index d0b4323..20a331f 100644 --- a/UsefulCombinators_0.4.0/prototypes/entity/entities.lua +++ b/UsefulCombinators_0.4.0/prototypes/entity/entities.lua @@ -791,7 +791,7 @@ data:extend({ collision_box = {{-0.35, -0.35}, {0.35, 0.35}}, selection_box = {{-0.5, -0.5}, {0.5, 0.5}}, - item_slot_count = 1, + item_slot_count = 2, sprites = { @@ -3587,4 +3587,4 @@ data:extend({ }, circuit_wire_max_distance = 7.5 } -}) \ No newline at end of file +})