diff options
Diffstat (limited to 'technic/machines/other')
-rw-r--r-- | technic/machines/other/injector.lua | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/technic/machines/other/injector.lua b/technic/machines/other/injector.lua index f803a25..b34dd79 100644 --- a/technic/machines/other/injector.lua +++ b/technic/machines/other/injector.lua @@ -1,6 +1,10 @@ local S = technic.getter +local fs_helpers = pipeworks.fs_helpers + +local tube_entry = "^pipeworks_tube_connection_metallic.png" + local function inject_items (pos) local meta=minetest.get_meta(pos) local inv = meta:get_inventory() @@ -51,38 +55,59 @@ minetest.register_craft({ local function set_injector_formspec(meta) local is_stack = meta:get_string("mode") == "whole stacks" meta:set_string("formspec", - "invsize[8,9;]".. - "item_image[0,0;1,1;technic:injector]".. - "label[1,0;"..S("Self-Contained Injector").."]".. - (is_stack and - "button[0,1;2,1;mode_item;"..S("Stackwise").."]" or - "button[0,1;2,1;mode_stack;"..S("Itemwise").."]").. - "list[current_name;main;0,2;8,2;]".. - "list[current_player;main;0,5;8,4;]".. - "listring[]") + "invsize[8,9;]".. + "item_image[0,0;1,1;technic:injector]".. + "label[1,0;"..S("Self-Contained Injector").."]".. + (is_stack and + "button[0,1;2,1;mode_item;"..S("Stackwise").."]" or + "button[0,1;2,1;mode_stack;"..S("Itemwise").."]").. + "list[current_name;main;0,2;8,2;]".. + "list[current_player;main;0,5;8,4;]".. + "listring[]".. + fs_helpers.cycling_button( + meta, + pipeworks.button_base, + "splitstacks", + { + pipeworks.button_off, + pipeworks.button_on + } + )..pipeworks.button_label + ) end minetest.register_node("technic:injector", { description = S("Self-Contained Injector"), - tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png", - "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"}, + tiles = { + "technic_injector_top.png"..tube_entry, + "technic_injector_bottom.png", + "technic_injector_side.png"..tube_entry, + "technic_injector_side.png"..tube_entry, + "technic_injector_side.png"..tube_entry, + "technic_injector_side.png" + }, + paramtype2 = "facedir", groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1}, tube = { can_insert = function(pos, node, stack, direction) - local onestack = stack:peek_item(1) - return minetest.get_meta(pos):get_inventory():room_for_item("main", onestack) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if meta:get_int("splitstacks") == 1 then + stack = stack:peek_item(1) + end + return meta:get_inventory():room_for_item("main", stack) end, insert_object = function(pos, node, stack, direction) return minetest.get_meta(pos):get_inventory():add_item("main", stack) end, - connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1}, + connect_sides = {left=1, right=1, back=1, top=1, bottom=1}, }, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Self-Contained Injector")) local inv = meta:get_inventory() - inv:set_size("main", 8*4) + inv:set_size("main", 8*2) meta:set_string("mode","single items") set_injector_formspec(meta) end, @@ -95,6 +120,12 @@ minetest.register_node("technic:injector", { local meta = minetest.get_meta(pos) if fields.mode_item then meta:set_string("mode", "single items") end if fields.mode_stack then meta:set_string("mode", "whole stacks") end + + if fields["fs_helpers_cycling:0:splitstacks"] + or fields["fs_helpers_cycling:1:splitstacks"] then + if not pipeworks.may_configure(pos, sender) then return end + fs_helpers.on_receive_fields(pos, fields) + end set_injector_formspec(meta) end, allow_metadata_inventory_put = technic.machine_inventory_put, |