Sorry but i can't update my mods anymore.
Most of my mods have a very unrestrictive license so feel free to take over...
This version is almost deprecated, please use https://mods.factorio.com/mod/LuaCombinator3 instead.
For a more restricted, server-friendly version, try https://mods.factorio.com/mod/SandboxedLuaCombinator by IWTDU
Overview:
Don't run this mod on a public server, it's vulnerable to infinite loops
Otherwise you probably won't be able to make it crash as its very sturdy.
You can copy the combinator's state & configuration to other lua combinators, and even blueprint them (only saves the code)
You can access the global[] table to share informations between all your combinators, don't worry, the mod's internal variables all end with a random number so you can't accidentally overwrite one. (global.combinators983, global.guis983, global.signals983)
Try to use the delay variable as much as possible, because if you let many combinators update on every tick it can eat quite some ups. (0.150 ups in 0.17 and 0.120 ups in 0.16 per combinator, if they read the network)
The following events are being occupied by the mod: (don't use them)
on_tick
on_gui_opened
on_gui_click
on_gui_closed
on_entity_settings_pasted
on_built_entity
on_robot_built_entity
on_pre_ghost_deconstructed
on_player_mined_entity
on_gui_text_changed
Here are a few variables to get you started:
combinator = the entity the script is running on
rednet [] = signals in the red network (read only) (Signal-name -> Value)
greennet [] = same for the green network
output [] = a table with all the signals you are sending to the networks, they are permanent so to remove a signal you need to set its entry to nil, or flush all signals by entering output = {} (creates a fresh table) (Signal-name -> Value)
var [] = a table to store all your combinator's variables between the ticks
delay = the delay in ticks until the next update (to save some ups) (not persistent, needs to be set on each update)
Credits:
Forum: Saving entity custom data to blueprint
Special thanks to:
BoxBox ( https://www.twitch.tv/boxbox - really nice streams, check it out!)
Arcani ( https://mods.factorio.com/user/Arcani_Victus )
James Austin
KiritoTRw
examples:
Clock:
var["time"] = (var["time"] or 0 ) + 1
output["signal-A"] =var["time"]
delay=60
Output highest signal:
local function get_highest_signal (signals)
local signal_name, signal_value = nil,0
for name, value in pairs(signals) do
if value > signal_value then
signal_value = value
signal_name = name
end
end
if signal_name then
return signal_name, signal_value
end
end
local red_name, red_value = get_highest_signal(rednet)
local green_name, green_value = get_highest_signal(greennet)
output = {} -- flushing the output signals
if red_name and red_value > green_value then
output[red_name] = red_value
elseif green_name then
output[green_name] = green_value
end
Accumulator charge history
local abc={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
for i = 1, 18 do
var[i] = var[i+1]
end
var[19] = greennet["signal-A"]
for i = 1 , 19 do
output["signal-"..abc[i]] = var[i] or 1
end
delay=1316 --1/19 day (25k ticks)
Blueprint String:
0eNrdnVtvG0cShf8Ln+XF9H3GDwvkfr/u4yIQZIlJCEiUQFHZNQL/9yXlbOLtqlPkEWYpo14S2JYozdenqrqm+3T/vnh1/bC826zW28XL3xery9v1/eLlP39f3K9+WV9c7/9u+/puuXi5WG2XN4uzxfriZv+n+5uL6+sX1xc3d4s3Z4vV+mr578XL8Obs4DdeLS9XV8vNi8vbm1er9cX2dvPOB8Q3P50tluvtartavv01Hv/w+nz9cPNqudn9hD8/Z/+Lbi/W23c/6Gxxd3u/+97b9f7H7z7vRRjOFq93/6+7n7H7ju3m9vr81fLXi99Wuy/ffc3Pq+vtcgOe+LfVZvuw+5u/HvrxK178slku14vHT3zYYwvD8A6Cn97+qPXycv+L3O8/L+z/8/a73nmm1dXjA795s6fWPWfUQMvHm+ynu1xtLh9W2/Pdv139+X0/rzb32/OjH3b523Lzevvrav3L2yd+S33xchr2f7q5u9g8on+5+Pv+3x/ul7ufdn27R7rdPCwBi83ySpDI+7FXIYV3AO3/nAG0dBy05ghagdByB60CaPk4aKMjaA1Cix20BKCV46AVR9AmCK120EYArR4HrfqBlgKEljpoBUBrx0FLjqAlCG3soIUBUBuPo5YdUcOVoHTUGoA2HQctOIKGK8FOWp3W0FRtP8U8hlt0xA0Xg9ZhmxC1cBQ1R2LLuBiEft4R0BQ3HNcYDI6w4b5g6qkFRO24zsBREc24HIS+MwioNQjH9QaOElseMba+Cw2oOQjHdQeOmoOM60Hou4OA2oNwXH/gaM5WIsbW9wcBNQjhuA7B0UuPghuE0HcIEXUI4bgWwVEzWirG1rcIAfUI4bgmwdF7yYJLAhRXPK4lcP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