Copy-Paste Recipe Signals

by zomis

Copying settings from an Assembling Machine to a combinator will paste one or more signals describing the recipe. On some entities it can be pasted again to switch the signal used

Utilities
4 months ago
0.18 - 1.1
1.18K
Circuit network

i [Fixed] T & S signals ignore assembler tier/modules

3 years ago
(updated 3 years ago)

Case 1:

  1. Select some recipe in assembler.
  2. Copypaste to combinator
  3. Insert some speed modules into assembler.
  4. Copypaste to another combinator

T & S in both combinators the same.

Case 2:

  1. Select some recipe in assembler.
  2. Copypaste to combinator
  3. Upgrade assembler to next tier.
  4. Copypaste to another combinator

T & S in both combinators the same.

As result it usable only if all machines the same, has same tier and same modules setup. (Or we need to calculate the correction coefficients manually)

UPD: now i decided to use lua combinators from "Moon logic" mod to fix this problem right in my game process.

3 years ago

Yes, this mod is currently only considering the speed taken of the recipe and not on any machines.

May I ask what your use-case is for using the T and S signals? I originally didn't think about including them but then I realized "why not" so I included them.

Care to share what you did with the Lua-combinators to fix the problem?

3 years ago

May I ask what your use-case is for using the T and S signals?

I try to make something like helmod... directly on the ground.
It must to calculate recipes chain and help to find a factory build.

Care to share what you did with the Lua-combinators to fix the problem?

Ok, but this is very early raw concept with lot of limitations (especially "hardware"). It's likely that it will be completely changed.

Software (lua code, same for all combinators):

--
-- input
--

out = {}

-- green: copy-paste mod data
--  NOTE: setting inverted!
--   * result negative
--   * ingredients positive

local time_def = green['signal-T']
if time_def <=0 then 
    -- error, no valid input
    out['signal-E'] = 1
    return
end


-- red: metadata
--  1. machine type
--  2. modules
--  3. some info:
--   * M   - amount of machines (1 by default)
--   * S+T - time of measuring  (1 minute by default)
--   * N   - assemby line id, generate unique signal if defined (higly optional)

local interval = red['signal-T'] + red['signal-S'] * 60
interval = interval > 0 and interval or 3600
-- out['signal-T'] = interval

local cnt = red['signal-M']
cnt = cnt > 0 and cnt or 1
out['signal-M'] = cnt

if red['signal-N'] > 0 then
    local N = 'signal-' .. red['signal-N']
    if pcall(function() local r = red[N] end) then
        -- 1..9  for vanila
        -- 1..99 for SchallVirtualSignal
        out[N] = cnt
    else
        -- out of range error
        out['signal-0'] = cnt
    end
end



--
-- sub
--

local function modif(tbl, var, fun)
    for k, v in pairs(tbl) do
        if red[k] > 0 then
            var = fun(var, v, red[k])
        end
    end
    return var
end 

local function bonus(tbl, var)
    local mod = modif(tbl, 0, function(var, v, n) 
        return var + v * n
    end)
    return var * (1 + mod)
end



--
-- main
--

-- mahine speed modifier

local prod_in = modif({
    ['assembling-machine-1'] = 0.5,
    ['assembling-machine-2'] = 0.75,
    ['assembling-machine-3'] = 1.25,

}, 1, function(var, v, n) 
    return var * v
end)


-- modules

prod_in = bonus({
    ['speed-module']   = 0.2,
    ['speed-module-2'] = 0.3,
    ['speed-module-3'] = 0.5,
    ['productivity-module']   = -0.05,
    ['productivity-module-2'] = -0.10,
    ['productivity-module-3'] = -0.15,
}, prod_in)

local prod_out = bonus({
    ['productivity-module']   = 0.04,
    ['productivity-module-2'] = 0.06,
    ['productivity-module-3'] = 0.10,
}, prod_in)


local time_in  = time_def / prod_in
local time_out = time_def / prod_out


-- final output

local cnt_in  = cnt * interval / time_in 
local cnt_out = cnt * interval / time_out

for k,v in pairs(green) do
    if not (k == 'signal-T' or k == 'signal-S') then

        -- we invert setting
        -- output negative, input positive

        if v > 0 then 
            -- input
            out[k] = v * cnt_in
        else 
            -- output
            out[k] = v * cnt_out
        end
    end
end

Hardware (blueprints)

Mods reiquired: Moon_Logic, Filter_Combinator.

Factory calculator: combinator

0eNq9V+2uojAQfZWbJvtnF+/SgvLxAPtvn2BjTIG5OgkUUopZY3j3bXG9ooJ8eOMfk9LO9Mw5M9PxSKK0gkKiUCQ8EoxzUZLwz5GUuBU8Nd/UoQASElSQEYsInpnVaXvxgakCuYjzLELBVS5JbREUCfwlIa2tQTdcotploDDu9sHqtUVAKFQIJ1zN4rARVRaB1Jd8usogwSpbQAqxktpfkaegLyryUhvnwkDQDhe+/b60yIGEnv++1BfpgIW2wCbuI6HmZysBRPs2TPRNtF7X2kAAbndRXkmDx7UoX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ejmD7wwbpU+rTgTfBLMfderr55dbv6I2ix4aZnkRZUW2S7PN1k6z5/87541

Build from left to right, from top to bottom, from final product to the ingredients. The first in the row is a combinator, next one or more assemblers.
Note: all assemblers in row must be same and has the same modules!

Example
Imagine that we do not know how to craft red circuits and decide to build this calculator for investigate it.
In first row we place red circuits recipe, in next its ingredients.
After this we can change assembler and modules type and amount inside constant combinators for find a good build.

Good build doubles two simple rules:
1. Make all intermediate ingredients negative.
2. Keep their values as low as possible.

This is example result (first found via this; not so good but it works at all):

0eNrtm0tv4zYQgP9KIaCXVmrFt5R7j+2lvRVBINtMQkCWVFkONgj830vJSSzLQ4kPJwiwe9ldR9HMcF4cfua+RKtyL5tWVV108xKpdV3topt/X6KdeqiKsv9Z99zI6CZSndxGcVQV2/7TtlxHhzhS1UZ+i27QIV584/g4uVdlJ9tkXW9Xqiq6uh2JwRZiit1Oblelqh6SbbF+VJVMyEgEsRGxeSqqtdwka9Wu96obvU4Pt3Ekq051Sh79MHx4vqv225Vs9UpPHpAbtd8mspTrrlXrpKlLqXU09U6/XFe9di0wQYj8xuLoObrh+h9ak/ZwpV9Rg6NfItT/8dBKWY3VqY1WlR9uD/qFSqqHx1W9b3uDcIzy236NE7uws12pOLfrTA2KSYxTSBFxV4RmFOEYU0gNfVfTZ2RXVN04ZSA34zct9M3NXVuXdyv5WDwp/Y7+xWPuWeW3Kc3W9b6vFLSQ+k+q7fb6J9Ps/wuUYZP3u0bqjN3Wm30pEzwSQ0+mIJ0wcIK1cjNNL6F/85j/w0fcJxsQCOYfCOYXCJPv/jT433/NyLBm7rxmdNXka8pi1+mKWhXtaM3Yqd0ey7KutJhRm7sQZZN667pp+pZdrHSBQ4nn23RfBSVo1H9dqumfkRDC03cpzEnK3yMp/F0GN+YV2Kwzu8wSJ3+0qnvcyj7MtrnFDZl1EnWnH2/Uu7n3qt11d9aOkLrR9b7YyV7M3VvuRzfas7XOgOJoV/SrfrPed83eWfbBvlTZyHuDR9HUw5Pn+DICcYQN0un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dXb9JJf+Vkfjfh1OnuzXQzY9gyhNiem2TX5yZZemVuAhSsYYhmZNajnNkecLjlF/eM+DPLq7TZV+D4IdQyWbr+6IgayRVQI3VDjdYlQ334l7DhX8zl2/zJHrxwpmH8OmiNw+MUEz5DGjIuATrJsKAv6o2W5+5S89zJ99z+dJdnTi7hIcA0Fwuu4djebuGU6JyE0c0s/dp0E5igYruus8RyhGkE5TSAbg7+/EE33cMnluIFzBFw+FgY3fyMigihm0Cem+Yp6lgRJt7PeSDdzD+cbpptFz50M7fajbL5g/fs9p+f083JNHipK/cLQfqJITABZpG6+um0CTq6SdhfODuNHlbBFtifqGbIEXORhTMutjjjTsEVJQbYKIg/PXVdGWcLC5lekxEQ8RtAsAH3iYC7ds6rmcICMQ2cYJD5PfY1IETBvGmlq/Wwa48Y9fZ4rVhbcfof2HFUFnqM1z/741uxbUr5032x1rvps37ypE/Ox9k6Q1TkWBBOaUrw4fA/Ep+qRA==

Note: first assembler has 4 speed-module-2.

3 years ago

Luckily it was fairly easy to add support for considering machine speed so I have now added a configuration option (defaults to false to be fully backwards-compatible) of whether to take machine speed into consideration. Also, I took the liberty of also adding support for furnaces :)

3 years ago

Big thanks!
Both look quite useful for me, furnaces too. ^_^

New response