mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-22 23:23:52 +01:00
Refine maximums given parallel machines.
This commit is contained in:
parent
abaaa69f5f
commit
39d94f5c48
@ -72,6 +72,14 @@ function me.reserve(net, pos, original_start, length)
|
|||||||
return start
|
return start
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local length = function(a)
|
||||||
|
local count = 0
|
||||||
|
for k,v in pairs(a) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
-- Testing: HV solar is realiable, big loans are screwy.
|
-- Testing: HV solar is realiable, big loans are screwy.
|
||||||
-- HV batteries are realiable.
|
-- HV batteries are realiable.
|
||||||
local function build(net, cpos, inv, name, count, stack, sink, time)
|
local function build(net, cpos, inv, name, count, stack, sink, time)
|
||||||
@ -83,6 +91,12 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
-- it only has 12 outputs.
|
-- it only has 12 outputs.
|
||||||
max = stack:get_stack_max()*12
|
max = stack:get_stack_max()*12
|
||||||
end
|
end
|
||||||
|
if net.process and net.process[name] then
|
||||||
|
max = max * length(net.process[name])
|
||||||
|
elseif net.autocrafters[name] then
|
||||||
|
max = max * length(net.autocrafters[name])
|
||||||
|
end
|
||||||
|
me.log("AC: max is "..max , "error")
|
||||||
if max and count > max then
|
if max and count > max then
|
||||||
local next_time = time
|
local next_time = time
|
||||||
local built = true
|
local built = true
|
||||||
@ -198,7 +212,8 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Consider looking up the recipe and finding the replacements that way.
|
-- Consider looking up the recipe and finding the replacements that way.
|
||||||
if name == "technic:copper_coil" or name == "technic:control_logic_unit" then
|
if name == "technic:copper_coil" or name == "technic:control_logic_unit"
|
||||||
|
or name == "technic:solar_panel" then
|
||||||
second_output = ItemStack("basic_materials:empty_spool 999")
|
second_output = ItemStack("basic_materials:empty_spool 999")
|
||||||
end
|
end
|
||||||
local craft_count = dat[1].ostack:get_count()
|
local craft_count = dat[1].ostack:get_count()
|
||||||
@ -265,7 +280,7 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
if hasit then
|
if hasit then
|
||||||
me.log("ac grabbing "..name, "error")
|
me.log("ac grabbing "..name, "error")
|
||||||
local grabbed = me.remove_item(net, inv, "main", istack)
|
local grabbed = me.remove_item(net, inv, "main", istack)
|
||||||
if grabbed then
|
if grabbed and grabbed:get_count() == count then
|
||||||
me.log("ac grabbed "..name, "error")
|
me.log("ac grabbed "..name, "error")
|
||||||
net.ac_status = net.ac_status .. time.." Grabbed "..count.." "..name..".\n"
|
net.ac_status = net.ac_status .. time.." Grabbed "..count.." "..name..".\n"
|
||||||
local slot = inv:get_size("ac")+1
|
local slot = inv:get_size("ac")+1
|
||||||
@ -288,6 +303,10 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
inv:set_stack("ac", slot, stack)
|
inv:set_stack("ac", slot, stack)
|
||||||
end] = name
|
end] = name
|
||||||
-- and then something moves the size of ac back to before we started
|
-- and then something moves the size of ac back to before we started
|
||||||
|
else
|
||||||
|
me.log("ac could not grab "..count.." "..name, "error")
|
||||||
|
net.ac_status = net.ac_status .. time.." Could not grab "..count.." "..name..".\n"
|
||||||
|
hasit = false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Try and autocraft it
|
-- Try and autocraft it
|
||||||
|
Loading…
Reference in New Issue
Block a user