diff --git a/basis/conf_inv.lua b/basis/conf_inv.lua index 1117ada..d738a69 100644 --- a/basis/conf_inv.lua +++ b/basis/conf_inv.lua @@ -10,9 +10,12 @@ Configured inventory lib Assuming the inventory has the name "conf" + Otherwise the name has to be provided as argument ]]-- +local StackName = ... or "conf" + -- for lazy programmers local M = minetest.get_meta @@ -22,7 +25,7 @@ function inv_lib.preassigned_stacks(pos, xsize, ysize) local inv = M(pos):get_inventory() local tbl = {} for idx = 1, xsize * ysize do - local item_name = inv:get_stack("conf", idx):get_name() + local item_name = inv:get_stack(StackName, idx):get_name() if item_name ~= "" then local x = (idx - 1) % xsize local y = math.floor((idx - 1) / xsize) @@ -36,7 +39,7 @@ function inv_lib.item_filter(pos, size) local inv = M(pos):get_inventory() local filter = {} for idx = 1, size do - local item_name = inv:get_stack("conf", idx):get_name() + local item_name = inv:get_stack(StackName, idx):get_name() if item_name == "" then item_name = "unconfigured" end if not filter[item_name] then filter[item_name] = {} diff --git a/basis/submenu.lua b/basis/submenu.lua index dba7378..46ce5da 100644 --- a/basis/submenu.lua +++ b/basis/submenu.lua @@ -129,7 +129,11 @@ local function generate_formspec_substring(pos, meta, form_def, player_name) tbl[#tbl+1] = "dropdown[4.72," .. (offs) .. ";5.5,1.4;" .. elem.name .. ";" .. elem.choices .. ";" .. idx .. "]" end elseif elem.type == "items" then -- inventory - tbl[#tbl+1] = "list[detached:" .. minetest.formspec_escape(player_name) .. "_techage_wrench_menu;cfg;4.75," .. offs .. ";" .. elem.size .. ",1;]" + if elem.size then + tbl[#tbl+1] = "list[detached:" .. minetest.formspec_escape(player_name) .. "_techage_wrench_menu;cfg;4.75," .. offs .. ";" .. elem.size .. ",1;]" + else + tbl[#tbl+1] = "list[detached:" .. minetest.formspec_escape(player_name) .. "_techage_wrench_menu;cfg;4.75," .. offs .. ";" .. elem.width .. "," .. elem.height .. ";]" + end player_inv_needed = true end end diff --git a/furnace/furnace_top.lua b/furnace/furnace_top.lua index b1c8aff..1838088 100644 --- a/furnace/furnace_top.lua +++ b/furnace/furnace_top.lua @@ -30,7 +30,19 @@ local reset_cooking = techage.furnace.reset_cooking local get_ingredients = techage.furnace.get_ingredients local check_if_worth_to_wakeup = techage.furnace.check_if_worth_to_wakeup local range = techage.in_range +local MP = minetest.get_modpath(minetest.get_current_modname()) +local mConf = assert(loadfile(MP .. "/basis/conf_inv.lua"))("cfg") +local WRENCH_MENU3 = { + { + type = "items", + name = "config", + label = S("Pre-Assignment Input Inv."), + tooltip = S("Stack locations can be pre-assigned to specific items,\nto be filled only with those items."), + width = 2, + height = 2, + } +} local function update_recipe_menu(pos, nvm) local ingr = get_ingredients(pos) @@ -47,7 +59,9 @@ local function formspec(self, pos, nvm) default.gui_bg.. default.gui_bg_img.. default.gui_slots.. + techage.wrench_image(7.6, -0.2) .. "list[context;src;0,0;2,2;]".. + mConf.preassigned_stacks(pos, 2, 2).. "image[2,0.5;1,1;techage_form_arrow_bg.png^[lowpart:".. (nvm.item_percent or 0)..":techage_form_arrow_fg.png^[transformR270]".. "image_button[2,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. @@ -237,9 +251,20 @@ local tubing = { end, on_push_item = function(pos, in_dir, stack, idx) local meta = minetest.get_meta(pos) - if meta:get_int("push_dir") == in_dir or in_dir == 5 then + if meta:get_int("push_dir") == in_dir or in_dir == 5 then local inv = M(pos):get_inventory() - return techage.put_items(inv, "src", stack, idx) + local mem = techage.get_mem(pos) + + mem.filter = mem.filter or mConf.item_filter(pos, 4) + mem.chest_configured = mem.chest_configured or not inv:is_empty("cfg") + + if mem.chest_configured then + local name = stack:get_name() + local stacks = mem.filter[name] or mem.filter["unconfigured"] + return mConf.put_items(pos, inv, "src", stack, stacks, idx) + else + return techage.put_items(inv, "src", stack, idx) + end end end, on_unpull_item = function(pos, in_dir, stack) @@ -283,6 +308,7 @@ local _, node_name_ta3, _ = local inv = M(pos):get_inventory() inv:set_size("src", 2*2) inv:set_size("dst", 2*2) + inv:set_size("cfg", 2*2) end, can_dig = can_dig, node_timer = keep_running, @@ -293,6 +319,8 @@ local _, node_name_ta3, _ = on_metadata_inventory_put = on_metadata_inventory, on_metadata_inventory_take = on_metadata_inventory, on_metadata_inventory_move = on_metadata_inventory, + ta3_formspec = WRENCH_MENU3, + on_rightclick = on_rightclick, groups = {choppy=2, cracky=2, crumbly=2}, sounds = default.node_sound_wood_defaults(), num_items = {0,1,1,1},