mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-29 18:33:51 +01:00
More cmon support.
This commit is contained in:
parent
b101a554ef
commit
1950c71f72
@ -122,9 +122,13 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
if dat.ostack:get_name() ~= name then
|
if dat.ostack:get_name() ~= name then
|
||||||
-- invalidate it
|
-- invalidate it
|
||||||
net.autocrafters[name][dat.apos] = nil
|
net.autocrafters[name][dat.apos] = nil
|
||||||
-- me.log("invalidating autocrafter", "error")
|
-- me.log("invalidating autocrafter for "..name, "error")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
-- Consider looking up the recipe and finding the replacements that way.
|
||||||
|
if name == "technic:copper_coil" or name == "technic:control_logic_unit" then
|
||||||
|
second_output = ItemStack("basic_materials:empty_spool 999")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
me.log("can't craft a "..name, "error")
|
me.log("can't craft a "..name, "error")
|
||||||
return
|
return
|
||||||
@ -182,6 +186,7 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
local grabbed = me.remove_item(net, inv, "main", istack)
|
local grabbed = me.remove_item(net, inv, "main", istack)
|
||||||
if grabbed then
|
if grabbed then
|
||||||
me.log("ac grabbed "..name, "error")
|
me.log("ac grabbed "..name, "error")
|
||||||
|
me.ac_status = me.ac_status .. "Grabbed "..count.." "..name..".\n"
|
||||||
local slot = inv:get_size("ac")+1
|
local slot = inv:get_size("ac")+1
|
||||||
inv:set_size("ac", slot)
|
inv:set_size("ac", slot)
|
||||||
inv:set_stack("ac", slot, grabbed)
|
inv:set_stack("ac", slot, grabbed)
|
||||||
@ -200,12 +205,14 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
else
|
else
|
||||||
-- Try and autocraft it
|
-- Try and autocraft it
|
||||||
me.log("AC: recursive crafting "..count.." "..istack:get_count(), "error")
|
me.log("AC: recursive crafting "..count.." "..istack:get_count(), "error")
|
||||||
|
me.ac_status = me.ac_status .. "Need to craft "..count.." "..name..".\n"
|
||||||
local built, step_time = build(net, cpos, inv, name, count, istack, dat.isink, time)
|
local built, step_time = build(net, cpos, inv, name, count, istack, dat.isink, time)
|
||||||
if built then
|
if built then
|
||||||
hasit = true
|
hasit = true
|
||||||
next_time = math.max(next_time, time + step_time)
|
next_time = math.max(next_time, time + step_time)
|
||||||
else
|
else
|
||||||
me.log("can't craft "..istack:get_count().." "..istack:get_name(), "error")
|
me.log("can't craft "..istack:get_count().." "..istack:get_name(), "error")
|
||||||
|
me.ac_status = me.ac_status .. "Can't craft "..count.." "..name..".\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
replace = replace and hasit
|
replace = replace and hasit
|
||||||
@ -277,12 +284,14 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
if dst_stack:get_count() ~= stack:get_count() then
|
if dst_stack:get_count() ~= stack:get_count() then
|
||||||
me.log("wow, missing items that should have been crafted "..stack:get_name(), "error")
|
me.log("wow, missing items that should have been crafted "..stack:get_name(), "error")
|
||||||
-- me.log("saw "..dst_stack:get_count().." items instead of "..stack:get_count().." items", "error")
|
-- me.log("saw "..dst_stack:get_count().." items instead of "..stack:get_count().." items", "error")
|
||||||
|
me.ac_status = me.ac_status .. "Missing "..(stack:get_count()-dst_stack:get_count()).." "..name..", only made "..dst_stack:get_count()..".\n"
|
||||||
end
|
end
|
||||||
if not dst_stack:is_empty() then
|
if not dst_stack:is_empty() then
|
||||||
me.log("TIMER: inserting "..dst_stack:get_count().." "..dst_stack:get_name(), "error")
|
me.log("TIMER: inserting "..dst_stack:get_count().." "..dst_stack:get_name(), "error")
|
||||||
local leftovers = sink(dst_stack)
|
local leftovers = sink(dst_stack)
|
||||||
if leftovers and not leftovers:is_empty() then
|
if leftovers and not leftovers:is_empty() then
|
||||||
me.log("autocrafter overflow, backpressuring", "error")
|
me.log("autocrafter overflow, backpressuring", "error")
|
||||||
|
me.ac_status = me.ac_status .. "Backpressure of "..name..".\n"
|
||||||
-- If any don't fit, back pressure on the crafter, we don't
|
-- If any don't fit, back pressure on the crafter, we don't
|
||||||
-- mean to do this, and want to chunk the crafting items smaller
|
-- mean to do this, and want to chunk the crafting items smaller
|
||||||
dat.rinv:add_item("dst", leftovers)
|
dat.rinv:add_item("dst", leftovers)
|
||||||
@ -299,6 +308,7 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
net:set_storage_space(true)
|
net:set_storage_space(true)
|
||||||
if leftovers and not leftovers:is_empty() then
|
if leftovers and not leftovers:is_empty() then
|
||||||
me.log("autocrafter overflow, backpressuring", "error")
|
me.log("autocrafter overflow, backpressuring", "error")
|
||||||
|
me.ac_status = me.ac_status .. "Backpressure of "..name..".\n"
|
||||||
-- If any don't fit, back pressure on the crafter, we don't
|
-- If any don't fit, back pressure on the crafter, we don't
|
||||||
-- mean to do this, and want to chunk the crafting items smaller
|
-- mean to do this, and want to chunk the crafting items smaller
|
||||||
dat.rinv:add_item("dst", leftovers)
|
dat.rinv:add_item("dst", leftovers)
|
||||||
@ -308,9 +318,10 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
|
|||||||
if second_output then
|
if second_output then
|
||||||
local second = dat.rinv:remove_item("dst", second_output)
|
local second = dat.rinv:remove_item("dst", second_output)
|
||||||
if second and not second:is_empty() then
|
if second and not second:is_empty() then
|
||||||
local leftovers = sink(second)
|
local leftovers = me.insert_item(second, net, inv, "main")
|
||||||
if leftovers and not leftovers:is_empty() then
|
if leftovers and not leftovers:is_empty() then
|
||||||
me.log("autocrafter overflow, backpressuring", "error")
|
me.log("autocrafter overflow, backpressuring", "error")
|
||||||
|
me.ac_status = me.ac_status .. "Backpressure of "..name..".\n"
|
||||||
-- If any don't fit, back pressure on the crafter, we don't
|
-- If any don't fit, back pressure on the crafter, we don't
|
||||||
-- mean to do this, and want to chunk the crafting items smaller
|
-- mean to do this, and want to chunk the crafting items smaller
|
||||||
dat.rinv:add_item("dst", leftovers)
|
dat.rinv:add_item("dst", leftovers)
|
||||||
@ -412,7 +423,7 @@ function me.autocraft(autocrafterCache, cpos, net, linv, inv, count)
|
|||||||
me.ac_status = me.ac_status .. "Crafting "..count.." "..name.." in "..step_time.." seconds.\n"
|
me.ac_status = me.ac_status .. "Crafting "..count.." "..name.." in "..step_time.." seconds.\n"
|
||||||
else
|
else
|
||||||
me.log("can't craft "..stack:get_count().." "..stack:get_name(), "error")
|
me.log("can't craft "..stack:get_count().." "..stack:get_name(), "error")
|
||||||
me.ac_status = me.ac_status .. "Can't craft "..count.." "..name.."."
|
me.ac_status = me.ac_status .. "Can't craft "..count.." "..name..".\n"
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ local function chest_formspec(pos, start_id, listname, page_max, q)
|
|||||||
if listname and (inv:get_size(listname) > 0 or net:get_item_capacity() > 0) then
|
if listname and (inv:get_size(listname) > 0 or net:get_item_capacity() > 0) then
|
||||||
local ctrlinvname = net:get_inventory_name()
|
local ctrlinvname = net:get_inventory_name()
|
||||||
list = "list[detached:"..ctrlinvname..";"
|
list = "list[detached:"..ctrlinvname..";"
|
||||||
.."ac;0,0.3;8,4;" .. (start_id - 1) .. "]"
|
.. listname .. ";0,0.3;4,4;" .. (start_id - 1) .. "]"
|
||||||
if minetest.get_modpath("i3") then
|
if minetest.get_modpath("i3") then
|
||||||
list = list .. [[
|
list = list .. [[
|
||||||
list[current_player;main;0,8.5;9,4;]
|
list[current_player;main;0,8.5;9,4;]
|
||||||
@ -36,18 +36,18 @@ local function chest_formspec(pos, start_id, listname, page_max, q)
|
|||||||
((net.pending and "running " .. #net.pending .. " steps\n") or "idle\n")
|
((net.pending and "running " .. #net.pending .. " steps\n") or "idle\n")
|
||||||
status = status .. (me.ac_status or "")
|
status = status .. (me.ac_status or "")
|
||||||
buttons = [[
|
buttons = [[
|
||||||
button[5.4,4.35;0.8,0.9;prev;<]
|
button[0.8,5.1;0.8,0.9;prev;<]
|
||||||
button[7.25,4.35;0.8,0.9;next;>]
|
button[2.65,5.1;0.8,0.9;next;>]
|
||||||
tooltip[prev;Previous]
|
tooltip[prev;Previous]
|
||||||
tooltip[next;Next]
|
tooltip[next;Next]
|
||||||
field[0.29,4.6;2.2,1;filter;;]]..query..[[]
|
field[0.29,4.6;2.2,1;filter;;]]..query..[[]
|
||||||
button[2.1,4.5;0.8,0.5;search;?]
|
button[2.1,4.5;0.8,0.5;search;?]
|
||||||
button[2.75,4.5;1.6,0.5;refresh;Refresh]
|
button[2.75,4.5;1.6,0.5;refresh;Refresh]
|
||||||
button[4.35,4.5;0.8,0.5;clear;X]
|
button[0,5.28;0.8,0.5;clear;X]
|
||||||
tooltip[search;Search]
|
tooltip[search;Search]
|
||||||
tooltip[refresh;Refresh]
|
tooltip[refresh;Refresh]
|
||||||
tooltip[clear;Reset]
|
tooltip[clear;Reset]
|
||||||
textarea[0.29,5.7;10,10;;]] .. status .. ";]"
|
textarea[4.75,0;4.65,12.5;;]] .. status .. ";]"
|
||||||
else
|
else
|
||||||
list = "label[3,2;" .. minetest.colorize("blue", "Crafter is idle") .. "]"
|
list = "label[3,2;" .. minetest.colorize("blue", "Crafter is idle") .. "]"
|
||||||
end
|
end
|
||||||
@ -55,7 +55,7 @@ local function chest_formspec(pos, start_id, listname, page_max, q)
|
|||||||
list = "label[3,2;" .. minetest.colorize("red", "No connected network!") .. "]"
|
list = "label[3,2;" .. minetest.colorize("red", "No connected network!") .. "]"
|
||||||
end
|
end
|
||||||
if page_max then
|
if page_max then
|
||||||
page_number = "label[6.15,4.5;" .. math.floor((start_id / 32)) + 1 ..
|
page_number = "label[1.55,5.25;" .. math.floor((start_id / 16)) + 1 ..
|
||||||
"/" .. page_max .."]"
|
"/" .. page_max .."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ local function update_chest(pos,_,ev)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local inv = net:get_inventory()
|
local inv = net:get_inventory()
|
||||||
local page_max = math.floor(inv:get_size("ac") / 32) + 1
|
local page_max = math.floor(inv:get_size("ac") / 16) + 1
|
||||||
|
|
||||||
meta:set_string("inv_name", "ac")
|
meta:set_string("inv_name", "ac")
|
||||||
meta:set_string("formspec", chest_formspec(pos, 1, "ac", page_max))
|
meta:set_string("formspec", chest_formspec(pos, 1, "ac", page_max))
|
||||||
@ -205,22 +205,22 @@ me.register_node("cmonitor", {
|
|||||||
inv = own_inv
|
inv = own_inv
|
||||||
assert(inv,"no own inv")
|
assert(inv,"no own inv")
|
||||||
end
|
end
|
||||||
local page_max = math.floor(inv:get_size(inv_name) / 32) + 1
|
local page_max = math.floor(inv:get_size(inv_name) / 16) + 1
|
||||||
if inv_name == "none" then
|
if inv_name == "none" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fields.next then
|
if fields.next then
|
||||||
if page + 32 > inv:get_size(inv_name) then
|
if page + 16 > inv:get_size(inv_name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
meta:set_int("page", page + 32)
|
meta:set_int("page", page + 16)
|
||||||
meta:set_string("formspec", chest_formspec(pos, page + 32, inv_name, page_max))
|
meta:set_string("formspec", chest_formspec(pos, page + 16, inv_name, page_max))
|
||||||
elseif fields.prev then
|
elseif fields.prev then
|
||||||
if page - 32 < 1 then
|
if page - 16 < 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
meta:set_int("page", page - 32)
|
meta:set_int("page", page - 16)
|
||||||
meta:set_string("formspec", chest_formspec(pos, page - 32, inv_name, page_max))
|
meta:set_string("formspec", chest_formspec(pos, page - 16, inv_name, page_max))
|
||||||
elseif fields.search or fields.key_enter_field == "filter" then
|
elseif fields.search or fields.key_enter_field == "filter" then
|
||||||
own_inv:set_size("search", 0)
|
own_inv:set_size("search", 0)
|
||||||
if fields.filter == "" then
|
if fields.filter == "" then
|
||||||
|
Loading…
Reference in New Issue
Block a user