summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-04-12 03:11:48 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-04-12 03:11:48 -0400
commit29881ec85e87e5bc186aded048af596e36e84597 (patch)
tree1372bbc080f3161014abe40db29e15fa59f43093
parent7af18188490f514e7768ca0aae7454134f85140f (diff)
downloaddreambuilder_modpack-29881ec85e87e5bc186aded048af596e36e84597.tar
dreambuilder_modpack-29881ec85e87e5bc186aded048af596e36e84597.tar.gz
dreambuilder_modpack-29881ec85e87e5bc186aded048af596e36e84597.tar.bz2
dreambuilder_modpack-29881ec85e87e5bc186aded048af596e36e84597.tar.xz
dreambuilder_modpack-29881ec85e87e5bc186aded048af596e36e84597.zip
updated technic and pipeworks
-rw-r--r--pipeworks/compat-chests.lua187
-rw-r--r--pipeworks/compat-furnaces.lua433
-rw-r--r--pipeworks/compat-old.lua157
-rw-r--r--pipeworks/init.lua10
-rw-r--r--pipeworks/sorting_tubes.lua8
-rw-r--r--pipeworks/textures/pipeworks_button_interm.pngbin5409 -> 5636 bytes
-rw-r--r--pipeworks/textures/pipeworks_button_off.pngbin5979 -> 6397 bytes
-rw-r--r--pipeworks/textures/pipeworks_button_on.pngbin6064 -> 6193 bytes
-rw-r--r--technic/machines/HV/forcefield.lua20
-rw-r--r--technic/machines/HV/quarry.lua17
-rw-r--r--technic/machines/LV/water_mill.lua13
-rw-r--r--technic/machines/MV/tool_workshop.lua15
-rw-r--r--technic/machines/other/injector.lua61
-rw-r--r--technic/machines/power_monitor.lua6
-rw-r--r--technic/machines/register/battery_box.lua93
-rw-r--r--technic/machines/register/generator.lua158
-rw-r--r--technic/machines/register/machine_base.lua99
-rw-r--r--technic/machines/supply_converter.lua13
-rw-r--r--technic/machines/switching_station.lua12
-rw-r--r--technic/textures/technic_cable_connection_overlay.pngbin0 -> 293 bytes
-rw-r--r--technic/textures/technic_supply_converter_bottom.pngbin738 -> 696 bytes
-rw-r--r--technic/textures/technic_supply_converter_tb.pngbin0 -> 656 bytes
-rw-r--r--technic/textures/technic_supply_converter_top.pngbin738 -> 707 bytes
-rw-r--r--technic_chests/common.lua7
-rw-r--r--technic_chests/register.lua58
25 files changed, 1258 insertions, 109 deletions
diff --git a/pipeworks/compat-chests.lua b/pipeworks/compat-chests.lua
new file mode 100644
index 0000000..ac5c219
--- /dev/null
+++ b/pipeworks/compat-chests.lua
@@ -0,0 +1,187 @@
+-- this bit of code modifies the default chests and furnaces to be compatible
+-- with pipeworks.
+--
+-- the formspecs found here are basically copies of the ones from minetest_game
+-- plus bits from pipeworks' sorting tubes
+
+local fs_helpers = pipeworks.fs_helpers
+
+tube_entry = "^pipeworks_tube_connection_wooden.png"
+
+local base_chest_formspec = "size[8,9]" ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "list[current_player;main;0,4.85;8,1;]" ..
+ "list[current_player;main;0,6.08;8,3;8]" ..
+ "listring[current_player;main]" ..
+ default.get_hotbar_bg(0,4.85)
+
+local function update_chest_formspec(pos)
+ local meta = minetest.get_meta(pos)
+ local formspec = base_chest_formspec ..
+ "list[current_name;main;0,0.3;8,4;]" ..
+ "listring[current_name;main]" ..
+ fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ meta:set_string("formspec", formspec)
+end
+
+minetest.override_item("default:chest", {
+ tiles = {
+ "default_chest_top.png"..tube_entry,
+ "default_chest_top.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_front.png"
+ },
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ 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 inv:room_for_item("main", stack)
+ end,
+ input_inventory = "main",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_size("main", 8*4)
+ update_chest_formspec(pos)
+ end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ update_chest_formspec(pos)
+ end,
+})
+
+-- =====================
+
+local function get_locked_chest_formspec(pos)
+ local spos = pos.x .. "," .. pos.y .. "," .. pos.z
+ local formspec = base_chest_formspec ..
+ "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
+ "listring[nodemeta:" .. spos .. ";main]"
+ return formspec
+end
+
+local function setup_locked_formspec(pos, meta)
+ meta:set_string("formspec",
+ get_locked_chest_formspec(pos) ..
+ fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ )
+end
+
+minetest.override_item("default:chest_locked", {
+ tiles = {
+ "default_chest_top.png"..tube_entry,
+ "default_chest_top.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_side.png"..tube_entry,
+ "default_chest_lock.png"
+ },
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ 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 inv:room_for_item("main", stack)
+ end,
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = function (pos, placer)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("owner", placer:get_player_name() or "")
+ meta:set_string("infotext", "Locked Chest (owned by "..
+ meta:get_string("owner")..")")
+ pipeworks.after_place(pos)
+ end,
+ on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
+ if default.can_interact_with_node(clicker, pos) then
+ local meta = minetest.get_meta(pos)
+ local formspec = meta:get_string("formspec")
+ print("on_rightclick")
+ print(dump(formspec))
+ setup_locked_formspec(pos, meta, clicker)
+ minetest.show_formspec(
+ clicker:get_player_name(),
+ "default:chest_locked",
+ get_locked_chest_formspec(pos)
+ )
+ end
+ return itemstack
+ end,
+ on_key_use = function(pos, player)
+ local secret = minetest.get_meta(pos):get_string("key_lock_secret")
+ local itemstack = player:get_wielded_item()
+ local key_meta = itemstack:get_meta()
+
+ if key_meta:get_string("secret") == "" then
+ key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
+ itemstack:set_metadata("")
+ end
+
+ if secret ~= key_meta:get_string("secret") then
+ return
+ end
+ setup_locked_formspec(pos, minetest.get_meta(pos))
+ end,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_size("main", 8*4)
+ setup_locked_formspec(pos, meta)
+ end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local formspec = get_locked_chest_formspec(pos)
+ print("on_receive_fields")
+ print(dump(formspec))
+
+ if formspec == "" then
+ meta:set_string("formspec", formspec)
+ else
+ setup_locked_formspec(pos, minetest.get_meta(pos))
+ end
+ end,
+ after_dig_node = pipeworks.after_dig
+})
diff --git a/pipeworks/compat-furnaces.lua b/pipeworks/compat-furnaces.lua
new file mode 100644
index 0000000..492332a
--- /dev/null
+++ b/pipeworks/compat-furnaces.lua
@@ -0,0 +1,433 @@
+
+-- this file is basically a modified copy of
+-- minetest_game/mods/default/furnaces.lua
+
+local fs_helpers = pipeworks.fs_helpers
+
+tube_entry = "^pipeworks_tube_connection_stony.png"
+
+local function active_formspec(fuel_percent, item_percent, pos, meta)
+ local formspec =
+ "size[8,8.5]"..
+ default.gui_bg..
+ default.gui_bg_img..
+ default.gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
+ (100-fuel_percent)..":default_furnace_fire_fg.png]"..
+ "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
+ (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.96;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ "listring[current_name;dst]"..
+ "listring[current_player;main]"..
+ "listring[current_name;src]"..
+ "listring[current_player;main]"..
+ "listring[current_name;fuel]"..
+ "listring[current_player;main]"..
+ default.get_hotbar_bg(0, 4.25) ..
+ fs_helpers.cycling_button(
+ meta,
+ "image_button[0,3.5;1,0.6",
+ "split_material_stacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ ).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
+ return formspec
+end
+
+local function inactive_formspec(pos, meta)
+ local formspec = "size[8,8.5]"..
+ default.gui_bg..
+ default.gui_bg_img..
+ default.gui_slots..
+ "list[current_name;src;2.75,0.5;1,1;]"..
+ "list[current_name;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
+ "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
+ "list[current_name;dst;4.75,0.96;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ "listring[current_name;dst]"..
+ "listring[current_player;main]"..
+ "listring[current_name;src]"..
+ "listring[current_player;main]"..
+ "listring[current_name;fuel]"..
+ "listring[current_player;main]"..
+ default.get_hotbar_bg(0, 4.25) ..
+ fs_helpers.cycling_button(
+ meta,
+ "image_button[0,3.5;1,0.6",
+ "split_material_stacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ ).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
+ return formspec
+end
+
+--
+-- Node callback functions that are the same for active and inactive furnace
+--
+
+local function can_dig(pos, player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src")
+end
+
+local function allow_metadata_inventory_put(pos, listname, index, stack, player)
+ if minetest.is_protected(pos, player:get_player_name()) then
+ return 0
+ end
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if listname == "fuel" then
+ if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
+ if inv:is_empty("src") then
+ meta:set_string("infotext", "Furnace is empty")
+ end
+ return stack:get_count()
+ else
+ return 0
+ end
+ elseif listname == "src" then
+ return stack:get_count()
+ elseif listname == "dst" then
+ return 0
+ end
+end
+
+local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local stack = inv:get_stack(from_list, from_index)
+ return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
+end
+
+local function allow_metadata_inventory_take(pos, listname, index, stack, player)
+ if minetest.is_protected(pos, player:get_player_name()) then
+ return 0
+ end
+ return stack:get_count()
+end
+
+local function swap_node(pos, name)
+ local node = minetest.get_node(pos)
+ if node.name == name then
+ return
+ end
+ node.name = name
+ minetest.swap_node(pos, node)
+end
+
+local function furnace_node_timer(pos, elapsed)
+ --
+ -- Inizialize metadata
+ --
+ local meta = minetest.get_meta(pos)
+ local fuel_time = meta:get_float("fuel_time") or 0
+ local src_time = meta:get_float("src_time") or 0
+ local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
+
+ local inv = meta:get_inventory()
+ local srclist, fuellist
+
+ local cookable, cooked
+ local fuel
+
+ local update = true
+ while update do
+ update = false
+
+ srclist = inv:get_list("src")
+ fuellist = inv:get_list("fuel")
+
+ --
+ -- Cooking
+ --
+
+ -- Check if we have cookable content
+ local aftercooked
+ cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
+ cookable = cooked.time ~= 0
+
+ -- Check if we have enough fuel to burn
+ if fuel_time < fuel_totaltime then
+ -- The furnace is currently active and has enough fuel
+ fuel_time = fuel_time + elapsed
+ -- If there is a cookable item then check if it is ready yet
+ if cookable then
+ src_time = src_time + elapsed
+ if src_time >= cooked.time then
+ -- Place result in dst list if possible
+ if inv:room_for_item("dst", cooked.item) then
+ inv:add_item("dst", cooked.item)
+ inv:set_stack("src", 1, aftercooked.items[1])
+ src_time = src_time - cooked.time
+ update = true
+ end
+ end
+ end
+ else
+ -- Furnace ran out of fuel
+ if cookable then
+ -- We need to get new fuel
+ local afterfuel
+ fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
+
+ if fuel.time == 0 then
+ -- No valid fuel in fuel list
+ fuel_totaltime = 0
+ src_time = 0
+ else
+ -- Take fuel from fuel list
+ inv:set_stack("fuel", 1, afterfuel.items[1])
+ update = true
+ fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime)
+ src_time = src_time + elapsed
+ end
+ else
+ -- We don't need to get new fuel since there is no cookable item
+ fuel_totaltime = 0
+ src_time = 0
+ end
+ fuel_time = 0
+ end
+
+ elapsed = 0
+ end
+
+ if fuel and fuel_totaltime > fuel.time then
+ fuel_totaltime = fuel.time
+ end
+ if srclist[1]:is_empty() then
+ src_time = 0
+ end
+
+ --
+ -- Update formspec, infotext and node
+ --
+ local formspec = inactive_formspec(pos, meta)
+ local item_state
+ local item_percent = 0
+ if cookable then
+ item_percent = math.floor(src_time / cooked.time * 100)
+ if item_percent > 100 then
+ item_state = "100% (output full)"
+ else
+ item_state = item_percent .. "%"
+ end
+ else
+ if srclist[1]:is_empty() then
+ item_state = "Empty"
+ else
+ item_state = "Not cookable"
+ end
+ end
+
+ local fuel_state = "Empty"
+ local active = "inactive "
+ local result = false
+
+ if fuel_totaltime ~= 0 then
+ active = "active "
+ local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
+ fuel_state = fuel_percent .. "%"
+ formspec = active_formspec(fuel_percent, item_percent, pos, meta)
+ swap_node(pos, "default:furnace_active")
+ -- make sure timer restarts automatically
+ result = true
+ else
+ if not fuellist[1]:is_empty() then
+ fuel_state = "0%"
+ end
+ swap_node(pos, "default:furnace")
+ -- stop timer on the inactive furnace
+ minetest.get_node_timer(pos):stop()
+ end
+
+ local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
+
+ --
+ -- Set meta values
+ --
+ meta:set_float("fuel_totaltime", fuel_totaltime)
+ meta:set_float("fuel_time", fuel_time)
+ meta:set_float("src_time", src_time)
+ meta:set_string("formspec", formspec)
+ meta:set_string("infotext", infotext)
+
+ return result
+end
+
+--
+-- Node definitions
+--
+
+minetest.register_node(":default:furnace", {
+ description = "Furnace",
+ tiles = {
+ "default_furnace_top.png"..tube_entry,
+ "default_furnace_bottom.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ "default_furnace_front.png"
+ },
+ groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local timer = minetest.get_node_timer(pos)
+ if not timer:is_started() then
+ timer:start(1.0)
+ end
+ if direction.y == 1 then
+ return inv:add_item("fuel", stack)
+ else
+ return inv:add_item("src", stack)
+ end
+ end,
+ can_insert = function(pos,node,stack,direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if direction.y == 1 then
+ return inv:room_for_item("fuel", stack)
+ else
+ if meta:get_int("split_material_stacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("src", stack)
+ end
+ end,
+ input_inventory = "dst",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ paramtype2 = "facedir",
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ sounds = default.node_sound_stone_defaults(),
+
+ can_dig = can_dig,
+
+ on_timer = furnace_node_timer,
+
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", inactive_formspec(pos, meta))
+ local inv = meta:get_inventory()
+ inv:set_size('src', 1)
+ inv:set_size('fuel', 1)
+ inv:set_size('dst', 4)
+ end,
+
+ on_metadata_inventory_move = function(pos)
+ minetest.get_node_timer(pos):start(1.0)
+ end,
+ on_metadata_inventory_put = function(pos)
+ -- start timer function, it will sort out whether furnace can burn or not.
+ minetest.get_node_timer(pos):start(1.0)
+ end,
+ on_blast = function(pos)
+ local drops = {}
+ default.get_inventory_drops(pos, "src", drops)
+ default.get_inventory_drops(pos, "fuel", drops)
+ default.get_inventory_drops(pos, "dst", drops)
+ drops[#drops+1] = "default:furnace"
+ minetest.remove_node(pos)
+ return drops
+ end,
+ allow_metadata_inventory_put = allow_metadata_inventory_put,
+ allow_metadata_inventory_move = allow_metadata_inventory_move,
+ allow_metadata_inventory_take = allow_metadata_inventory_take,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local formspec = inactive_formspec(pos, meta)
+ meta:set_string("formspec", formspec)
+ end,
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig
+})
+
+minetest.register_node(":default:furnace_active", {
+ description = "Furnace",
+ tiles = {
+ "default_furnace_top.png"..tube_entry,
+ "default_furnace_bottom.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ "default_furnace_side.png"..tube_entry,
+ {
+ image = "default_furnace_front_active.png",
+ backface_culling = false,
+ animation = {
+ type = "vertical_frames",
+ aspect_w = 16,
+ aspect_h = 16,
+ length = 1.5
+ },
+ }
+ },
+ groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1, not_in_creative_inventory = 1},
+ tube = {
+ insert_object = function(pos,node,stack,direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local timer = minetest.get_node_timer(pos)
+ if not timer:is_started() then
+ timer:start(1.0)
+ end
+ if direction.y == 1 then
+ return inv:add_item("fuel", stack)
+ else
+ return inv:add_item("src", stack)
+ end
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if direction.y == 1 then
+ return inv:room_for_item("fuel", stack)
+ else
+ if meta:get_int("split_material_stacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("src", stack)
+ end
+ end,
+ input_inventory = "dst",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ paramtype2 = "facedir",
+ light_source = 8,
+ drop = "default:furnace",
+ legacy_facedir_simple = true,
+ is_ground_content = false,
+ sounds = default.node_sound_stone_defaults(),
+ on_timer = furnace_node_timer,
+
+ can_dig = can_dig,
+
+ allow_metadata_inventory_put = allow_metadata_inventory_put,
+ allow_metadata_inventory_move = allow_metadata_inventory_move,
+ allow_metadata_inventory_take = allow_metadata_inventory_take,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local formspec = active_formspec(0, 0, pos, meta)
+ meta:set_string("formspec", formspec)
+ end,
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig
+})
+
diff --git a/pipeworks/compat-old.lua b/pipeworks/compat-old.lua
new file mode 100644
index 0000000..c0e5e8c
--- /dev/null
+++ b/pipeworks/compat-old.lua
@@ -0,0 +1,157 @@
+-- this bit of code modifies the default chests and furnaces to be compatible
+-- with pipeworks.
+
+minetest.override_item("default:furnace", {
+ tiles = {
+ "default_furnace_top.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_bottom.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_front.png"
+ },
+ groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local timer = minetest.get_node_timer(pos)
+ if not timer:is_started() then
+ timer:start(1.0)
+ end
+ if direction.y == 1 then
+ return inv:add_item("fuel",stack)
+ else
+ return inv:add_item("src",stack)
+ end
+ end,
+ can_insert = function(pos,node,stack,direction)
+ local onestack = stack:peek_item(1)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if direction.y == 1 then
+ return inv:room_for_item("fuel", onestack)
+ else
+ return inv:room_for_item("src", onestack)
+ end
+ end,
+ input_inventory = "dst",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig
+})
+
+minetest.override_item("default:furnace_active", {
+ tiles = {
+ "default_furnace_top.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_bottom.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ "default_furnace_side.png^pipeworks_tube_connection_stony.png",
+ {
+ image = "default_furnace_front_active.png",
+ backface_culling = false,
+ animation = {
+ type = "vertical_frames",
+ aspect_w = 16,
+ aspect_h = 16,
+ length = 1.5
+ },
+ }
+ },
+ groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1, not_in_creative_inventory = 1},
+ tube = {
+ insert_object = function(pos,node,stack,direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local timer = minetest.get_node_timer(pos)
+ if not timer:is_started() then
+ timer:start(1.0)
+ end
+ if direction.y == 1 then
+ return inv:add_item("fuel", stack)
+ else
+ return inv:add_item("src", stack)
+ end
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local onestack = stack:peek_item(1)
+ if direction.y == 1 then
+ return inv:room_for_item("fuel", onestack)
+ else
+ return inv:room_for_item("src", onestack)
+ end
+ end,
+ input_inventory = "dst",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig
+})
+
+minetest.override_item("default:chest", {
+ tiles = {
+ "default_chest_top.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_top.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_front.png"
+ },
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local onestack = stack:peek_item(1)
+ return inv:room_for_item("main", onestack)
+ end,
+ input_inventory = "main",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = pipeworks.after_place,
+ after_dig_node = pipeworks.after_dig
+})
+
+minetest.override_item("default:chest_locked", {
+ tiles = {
+ "default_chest_top.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_top.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_side.png^pipeworks_tube_connection_wooden.png",
+ "default_chest_lock.png"
+ },
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ local onestack = stack:peek_item(1)
+ return inv:room_for_item("main", onestack)
+ end,
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ },
+ after_place_node = function (pos, placer)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("owner", placer:get_player_name() or "")
+ meta:set_string("infotext", "Locked Chest (owned by "..
+ meta:get_string("owner")..")")
+ pipeworks.after_place(pos)
+ end,
+ after_dig_node = pipeworks.after_dig
+})
+
diff --git a/pipeworks/init.lua b/pipeworks/init.lua
index 499f6ba..ab5cf3c 100644
--- a/pipeworks/init.lua
+++ b/pipeworks/init.lua
@@ -41,6 +41,11 @@ pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z
pipeworks.liquid_texture = "default_water.png"
+pipeworks.button_off = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
+pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
+pipeworks.button_base = "image_button[0,4.3;1,0.6"
+pipeworks.button_label = "label[0.9,4.31;Allow splitting incoming stacks from tubes]"
+
-- Helper functions
function pipeworks.fix_image_names(table, replacement)
@@ -108,7 +113,10 @@ dofile(pipeworks.modpath.."/wielder.lua")
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
-if pipeworks.enable_redefines then dofile(pipeworks.modpath.."/compat.lua") end
+if pipeworks.enable_redefines then
+ dofile(pipeworks.modpath.."/compat-chests.lua")
+ dofile(pipeworks.modpath.."/compat-furnaces.lua")
+end
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
diff --git a/pipeworks/sorting_tubes.lua b/pipeworks/sorting_tubes.lua
index 0d6ec2a..e7e918d 100644
--- a/pipeworks/sorting_tubes.lua
+++ b/pipeworks/sorting_tubes.lua
@@ -15,8 +15,12 @@ if pipeworks.enable_mese_tube then
local buttons_formspec = ""
for i = 0, 5 do
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
- "image_button[7,"..(i)..";1,1", "l"..(i+1).."s",
- {{text="",texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}, {text="",texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}})
+ "image_button[7,"..(i+0.2)..";1,0.6", "l"..(i+1).."s",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )
end
meta:set_string("formspec",
"size[8,11]"..
diff --git a/pipeworks/textures/pipeworks_button_interm.png b/pipeworks/textures/pipeworks_button_interm.png
index 47320ce..0d4c558 100644
--- a/pipeworks/textures/pipeworks_button_interm.png
+++ b/pipeworks/textures/pipeworks_button_interm.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_button_off.png b/pipeworks/textures/pipeworks_button_off.png
index 319fc6e..3836d19 100644
--- a/pipeworks/textures/pipeworks_button_off.png
+++ b/pipeworks/textures/pipeworks_button_off.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_button_on.png b/pipeworks/textures/pipeworks_button_on.png
index a9884cf..a42eb05 100644
--- a/pipeworks/textures/pipeworks_button_on.png
+++ b/pipeworks/textures/pipeworks_button_on.png
Binary files differ
diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua
index 1d46bcf..3bb8d03 100644
--- a/technic/machines/HV/forcefield.lua
+++ b/technic/machines/HV/forcefield.lua
@@ -12,6 +12,8 @@ local forcefield_power_drain = 10
local S = technic.getter
+local cable_entry = "^technic_cable_connection_overlay.png"
+
minetest.register_craft({
output = "technic:forcefield_emitter_off",
recipe = {
@@ -258,7 +260,14 @@ end
minetest.register_node("technic:forcefield_emitter_off", {
description = S("%s Forcefield Emitter"):format("HV"),
- tiles = {"technic_forcefield_emitter_off.png"},
+ tiles = {
+ "technic_forcefield_emitter_off.png",
+ "technic_machine_bottom.png"..cable_entry,
+ "technic_forcefield_emitter_off.png",
+ "technic_forcefield_emitter_off.png",
+ "technic_forcefield_emitter_off.png",
+ "technic_forcefield_emitter_off.png"
+ },
groups = {cracky = 1, technic_machine = 1, technic_hv = 1},
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
@@ -282,7 +291,14 @@ minetest.register_node("technic:forcefield_emitter_off", {
minetest.register_node("technic:forcefield_emitter_on", {
description = S("%s Forcefield Emitter"):format("HV"),
- tiles = {"technic_forcefield_emitter_on.png"},
+ tiles = {
+ "technic_forcefield_emitter_on.png",
+ "technic_machine_bottom.png"..cable_entry,
+ "technic_forcefield_emitter_on.png",
+ "technic_forcefield_emitter_on.png",
+ "technic_forcefield_emitter_on.png",
+ "technic_forcefield_emitter_on.png"
+ },
groups = {cracky = 1, technic_machine = 1, technic_hv = 1,
not_in_creative_inventory=1},
drop = "technic:forcefield_emitter_off",
diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua
index 8d87b65..c1ee1bb 100644
--- a/technic/machines/HV/quarry.lua
+++ b/technic/machines/HV/quarry.lua
@@ -1,6 +1,9 @@
local S = technic.getter
+local tube_entry = "^pipeworks_tube_connection_metallic.png"
+local cable_entry = "^technic_cable_connection_overlay.png"
+
minetest.register_craft({
recipe = {
{"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"},
@@ -207,12 +210,14 @@ end
minetest.register_node("technic:quarry", {
description = S("%s Quarry"):format("HV"),
- tiles = {"technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
- "technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
- "technic_carbon_steel_block.png^default_tool_mesepick.png", "technic_carbon_steel_block.png"},
- inventory_image = minetest.inventorycube("technic_carbon_steel_block.png",
- "technic_carbon_steel_block.png^default_tool_mesepick.png",
- "technic_carbon_steel_block.png"),
+ tiles = {
+ "technic_carbon_steel_block.png"..tube_entry,
+ "technic_carbon_steel_block.png"..cable_entry,
+ "technic_carbon_steel_block.png"..cable_entry,
+ "technic_carbon_steel_block.png"..cable_entry,
+ "technic_carbon_steel_block.png^default_tool_mesepick.png",
+ "technic_carbon_steel_block.png"..cable_entry
+ },
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1},
connect_sides = {"bottom", "front", "left", "right"},
diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua
index d291332..5d871f0 100644
--- a/technic/machines/LV/water_mill.lua
+++ b/technic/machines/LV/water_mill.lua
@@ -4,6 +4,8 @@
local S = technic.getter
+local cable_entry = "^technic_cable_connection_overlay.png"
+
minetest.register_alias("water_mill", "technic:water_mill")
minetest.register_craft({
@@ -68,9 +70,14 @@ end
minetest.register_node("technic:water_mill", {
description = S("Hydro %s Generator"):format("LV"),
- tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
- "technic_water_mill_side.png", "technic_water_mill_side.png",
- "technic_water_mill_side.png", "technic_water_mill_side.png"},
+ tiles = {
+ "technic_water_mill_top.png",
+ "technic_machine_bottom.png"..cable_entry,
+ "technic_water_mill_side.png",
+ "technic_water_mill_side.png",
+ "technic_water_mill_side.png",
+ "technic_water_mill_side.png"
+ },
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
technic_machine=1, technic_lv=1},
diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua
index 9219717..6679d1d 100644
--- a/technic/machines/MV/tool_workshop.lua
+++ b/technic/machines/MV/tool_workshop.lua
@@ -5,6 +5,8 @@ minetest.register_alias("tool_workshop", "technic:tool_workshop")
local S = technic.getter
+local tube_entry = "^pipeworks_tube_connection_wooden.png"
+
minetest.register_craft({
output = 'technic:tool_workshop',
recipe = {
@@ -83,8 +85,14 @@ end
minetest.register_node("technic:tool_workshop", {
description = S("%s Tool Workshop"):format("MV"),
paramtype2 = "facedir",
- tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
- "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
+ tiles = {
+ "technic_workshop_top.png"..tube_entry,
+ "technic_machine_bottom.png"..tube_entry,
+ "technic_workshop_side.png"..tube_entry,
+ "technic_workshop_side.png"..tube_entry,
+ "technic_workshop_side.png"..tube_entry,
+ "technic_workshop_side.png"
+ },
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
technic_machine=1, technic_mv=1, tubedevice=1, tubedevice_receiver=1},
connect_sides = {"bottom", "back", "left", "right"},
@@ -103,8 +111,7 @@ minetest.register_node("technic:tool_workshop", {
allow_metadata_inventory_take = technic.machine_inventory_take,
tube = {
can_insert = function (pos, node, stack, direction)
- local onestack = stack:peek_item(1)
- return minetest.get_meta(pos):get_inventory():room_for_item("src", onestack)
+ return minetest.get_meta(pos):get_inventory():room_for_item("src", stack)
end,
insert_object = function (pos, node, stack, direction)
return minetest.get_meta(pos):get_inventory():add_item("src", stack)
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,
diff --git a/technic/machines/power_monitor.lua b/technic/machines/power_monitor.lua
index 8c5bed6..4d722a2 100644
--- a/technic/machines/power_monitor.lua
+++ b/technic/machines/power_monitor.lua
@@ -4,6 +4,8 @@
local S = technic.getter
+local cable_entry = "^technic_cable_connection_overlay.png"
+
minetest.register_craft({
output = "technic:power_monitor",
recipe = {
@@ -17,10 +19,10 @@ minetest.register_node("technic:power_monitor",{
description = S("Power Monitor"),
tiles = {
"technic_power_monitor_sides.png",
- "technic_power_monitor_bottom_back.png",
+ "technic_power_monitor_sides.png"..cable_entry,
"technic_power_monitor_sides.png",
"technic_power_monitor_sides.png",
- "technic_power_monitor_bottom_back.png",
+ "technic_power_monitor_sides.png"..cable_entry,
"technic_power_monitor_front.png"
},
paramtype2 = "facedir",
diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua
index 2a45b13..7238d6d 100644
--- a/technic/machines/register/battery_box.lua
+++ b/technic/machines/register/battery_box.lua
@@ -2,6 +2,9 @@
local digilines_path = minetest.get_modpath("digilines")
local S = technic.getter
+local tube_entry = "^pipeworks_tube_connection_metallic.png"
+
+local fs_helpers = pipeworks.fs_helpers
technic.register_power_tool("technic:battery", 10000)
technic.register_power_tool("technic:red_energy_crystal", 50000)
@@ -50,16 +53,49 @@ local tube = {
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- local onestack = stack:peek_item(1)
if direction.y > 0 then
- return inv:room_for_item("src", onestack)
+ if meta:get_int("split_src_stacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("src", stack)
else
- return inv:room_for_item("dst", onestack)
+ if meta:get_int("split_dst_stacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("dst", stack)
end
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
}
+local function add_on_off_buttons(meta, ltier, charge_percent)
+ local formspec = ""
+ if ltier == "mv" or ltier == "hv" then
+ formspec = "image[1,1;1,2;technic_power_meter_bg.png"
+ .."^[lowpart:"..charge_percent
+ ..":technic_power_meter_fg.png]"..
+ fs_helpers.cycling_button(
+ meta,
+ "image_button[3,2.0;1,0.6",
+ "split_src_stacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ ).."label[3.9,2.01;Allow splitting incoming 'charge' stacks from tubes]"..
+ fs_helpers.cycling_button(
+ meta,
+ "image_button[3,2.5;1,0.6",
+ "split_dst_stacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ ).."label[3.9,2.51;Allow splitting incoming 'discharge' stacks]"
+ end
+ return formspec
+end
+
function technic.register_battery_box(data)
local tier = data.tier
local ltier = string.lower(tier)
@@ -79,6 +115,7 @@ function technic.register_battery_box(data)
"listring[current_player;main]"..
"listring[context;src]"..
"listring[current_player;main]"
+
if digilines_path then
formspec = formspec.."button[0.6,3.7;2,1;edit_channel;edit Channel]"
end
@@ -150,12 +187,7 @@ function technic.register_battery_box(data)
end
local charge_percent = math.floor(current_charge / max_charge * 100)
- meta:set_string("formspec",
- formspec..
- "image[1,1;1,2;technic_power_meter_bg.png"
- .."^[lowpart:"..charge_percent
- ..":technic_power_meter_fg.png]")
-
+ meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, charge_percent))
local infotext = S("@1 Battery Box: @2/@3", tier,
technic.pretty_num(current_charge), technic.pretty_num(max_charge))
if eu_input == 0 then
@@ -176,11 +208,16 @@ function technic.register_battery_box(data)
groups.tubedevice_receiver = 1
end
+ local tentry = tube_entry
+ if ltier == "lv" then
+ tentry = ""
+ end
+
minetest.register_node("technic:"..ltier.."_battery_box"..i, {
description = S("%s Battery Box"):format(tier),
tiles = {
- "technic_"..ltier.."_battery_box_top.png",
- "technic_"..ltier.."_battery_box_bottom.png",
+ "technic_"..ltier.."_battery_box_top.png"..tentry,
+ "technic_"..ltier.."_battery_box_bottom.png"..tentry,
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
@@ -193,11 +230,17 @@ function technic.register_battery_box(data)
drop = "technic:"..ltier.."_battery_box0",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
+ local EU_upgrade, tube_upgrade = 0, 0
+ if data.upgrade then
+ EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
+ end
+ local max_charge = data.max_charge * (1 + EU_upgrade / 10)
+ local charge = meta:get_int("internal_EU_charge")
+ local cpercent = math.floor(charge / max_charge * 100)
local inv = meta:get_inventory()
local node = minetest.get_node(pos)
-
meta:set_string("infotext", S("%s Battery Box"):format(tier))
- meta:set_string("formspec", formspec)
+ meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, cpercent))
meta:set_string("channel", ltier.."_battery_box"..minetest.pos_to_string(pos))
meta:set_int(tier.."_EU_demand", 0)
meta:set_int(tier.."_EU_supply", 0)
@@ -216,13 +259,28 @@ function technic.register_battery_box(data)
after_place_node = data.tube and pipeworks.after_place,
after_dig_node = technic.machine_after_dig_node,
on_receive_fields = function(pos, formname, fields, sender)
- if not fields.edit_channel then
- return
- end
local meta = minetest.get_meta(pos)
- minetest.show_formspec(sender:get_player_name(),
+ local nodename = minetest.get_node(pos).name
+ if fields.edit_channel then
+ minetest.show_formspec(sender:get_player_name(),
"technic:battery_box_edit_channel"..minetest.pos_to_string(pos),
"field[channel;Digiline Channel;"..meta:get_string("channel").."]")
+ elseif fields["fs_helpers_cycling:0:split_src_stacks"]
+ or fields["fs_helpers_cycling:0:split_dst_stacks"]
+ or fields["fs_helpers_cycling:1:split_src_stacks"]
+ or fields["fs_helpers_cycling:1:split_dst_stacks"] then
+ local meta = minetest.get_meta(pos)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local EU_upgrade, tube_upgrade = 0, 0
+ if data.upgrade then
+ EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
+ end
+ local max_charge = data.max_charge * (1 + EU_upgrade / 10)
+ local charge = meta:get_int("internal_EU_charge")
+ local cpercent = math.floor(charge / max_charge * 100)
+ meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, cpercent))
+ end
end,
digiline = {
receptor = {action = function() end},
@@ -278,7 +336,6 @@ minetest.register_on_player_receive_fields(
end
)
-
function technic.charge_tools(meta, batt_charge, charge_step)
local inv = meta:get_inventory()
if inv:is_empty("src") then
diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua
index f3ada1f..9062d09 100644
--- a/technic/machines/register/generator.lua
+++ b/technic/machines/register/generator.lua
@@ -1,5 +1,8 @@
local S = technic.getter
+local fs_helpers = pipeworks.fs_helpers
+local tube_entry = "^pipeworks_tube_connection_metallic.png"
+
local tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
@@ -9,13 +12,16 @@ local tube = {
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- local onestack = stack:peek_item(1)
- return inv:room_for_item("src", onestack)
+ if meta:get_int("splitstacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("src", stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
}
-function technic.register_generator(data)
+function technic.register_generator(data)
+
local tier = data.tier
local ltier = string.lower(tier)
@@ -77,21 +83,41 @@ function technic.register_generator(data)
if burn_totaltime == 0 then burn_totaltime = 1 end
local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("infotext", desc.." ("..percent.."%)")
- meta:set_string("formspec",
- "size[8, 9]"..
- "label[0, 0;"..minetest.formspec_escape(desc).."]"..
- "list[current_name;src;3, 1;1, 1;]"..
- "image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
- (percent)..":default_furnace_fire_fg.png]"..
- "list[current_player;main;0, 5;8, 4;]"..
- "listring[]")
+
+ local form_buttons = ""
+ if ltier ~= "lv" then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+ meta:set_string("formspec",
+ "size[8, 9]"..
+ "label[0, 0;"..minetest.formspec_escape(desc).."]"..
+ "list[current_name;src;3, 1;1, 1;]"..
+ "image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
+ (percent)..":default_furnace_fire_fg.png]"..
+ "list[current_player;main;0, 5;8, 4;]"..
+ "listring[]"..
+ form_buttons
+ )
end
-
+
minetest.register_node("technic:"..ltier.."_generator", {
description = desc,
- tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
- "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
- "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"},
+ tiles = {
+ "technic_"..ltier.."_generator_top.png"..tube_entry,
+ "technic_machine_bottom.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_front.png"
+ },
paramtype2 = "facedir",
groups = groups,
connect_sides = {"bottom", "back", "left", "right"},
@@ -100,11 +126,24 @@ function technic.register_generator(data)
tube = data.tube and tube or nil,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
+ local node = minetest.get_node(pos)
meta:set_string("infotext", desc)
meta:set_int(data.tier.."_EU_supply", 0)
meta:set_int("burn_time", 0)
meta:set_int("tube_time", 0)
- meta:set_string("formspec", generator_formspec)
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+ meta:set_string("formspec", generator_formspec..form_buttons)
local inv = meta:get_inventory()
inv:set_size("src", 1)
end,
@@ -114,14 +153,39 @@ function technic.register_generator(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
after_place_node = data.tube and pipeworks.after_place,
- after_dig_node = technic.machine_after_dig_node
+ after_dig_node = technic.machine_after_dig_node,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local node = minetest.get_node(pos)
+ local form = generator_formspec
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+ meta:set_string("formspec", generator_formspec..form_buttons)
+ end,
})
minetest.register_node("technic:"..ltier.."_generator_active", {
description = desc,
- tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
- "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
- "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
+ tiles = {
+ "technic_"..ltier.."_generator_top.png"..tube_entry,
+ "technic_machine_bottom.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_side.png"..tube_entry,
+ "technic_"..ltier.."_generator_front_active.png"
+ },
paramtype2 = "facedir",
groups = active_groups,
connect_sides = {"bottom"},
@@ -130,6 +194,7 @@ function technic.register_generator(data)
tube = data.tube and tube or nil,
drop = "technic:"..ltier.."_generator",
can_dig = technic.machine_can_dig,
+ after_dig_node = technic.machine_after_dig_node,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
@@ -140,7 +205,8 @@ function technic.register_generator(data)
end,
on_timer = function(pos, node)
local meta = minetest.get_meta(pos)
-
+ local node = minetest.get_node(pos)
+
-- Connected back?
if meta:get_int(tier.."_EU_timeout") > 0 then return false end
@@ -158,6 +224,19 @@ function technic.register_generator(data)
burn_time = burn_time - 1
meta:set_int("burn_time", burn_time)
local percent = math.floor(burn_time / burn_totaltime * 100)
+
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
meta:set_string("formspec",
"size[8, 9]"..
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
@@ -165,9 +244,44 @@ function technic.register_generator(data)
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
(percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0, 5;8, 4;]"..
- "listring[]")
+ "listring[]"..
+ form_buttons
+ )
return true
end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local node = minetest.get_node(pos)
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+
+ local burn_totaltime = meta:get_int("burn_totaltime") or 0
+ local burn_time = meta:get_int("burn_time")
+ local percent = math.floor(burn_time / burn_totaltime * 100)
+
+ meta:set_string("formspec",
+ "size[8, 9]"..
+ "label[0, 0;"..minetest.formspec_escape(desc).."]"..
+ "list[current_name;src;3, 1;1, 1;]"..
+ "image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
+ (percent)..":default_furnace_fire_fg.png]"..
+ "list[current_player;main;0, 5;8, 4;]"..
+ "listring[]"..
+ form_buttons
+ )
+ end,
})
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)
diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua
index d479773..0c6a6b3 100644
--- a/technic/machines/register/machine_base.lua
+++ b/technic/machines/register/machine_base.lua
@@ -1,6 +1,9 @@
local S = technic.getter
+local fs_helpers = pipeworks.fs_helpers
+local tube_entry = "^pipeworks_tube_connection_metallic.png"
+
local tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
@@ -10,8 +13,10 @@ local tube = {
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- local onestack = stack:peek_item(1)
- return inv:room_for_item("src", onestack)
+ if meta:get_int("splitstacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("src", stack)
end,
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
}
@@ -134,15 +139,21 @@ function technic.register_base_machine(data)
inv:set_list("dst", inv:get_list("dst_tmp"))
end
end
-
+
+ local tentry = tube_entry
+ if ltier == "lv" then
+ tentry = ""
+ end
minetest.register_node("technic:"..ltier.."_"..machine_name, {
description = machine_desc:format(tier),
- tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
- "technic_"..ltier.."_"..machine_name.."_bottom.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_front.png"},
+ tiles = {
+ "technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_front.png"
+ },
paramtype2 = "facedir",
groups = groups,
tube = data.tube and tube or nil,
@@ -152,9 +163,23 @@ function technic.register_base_machine(data)
on_construct = function(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
+
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+
meta:set_string("infotext", machine_desc:format(tier))
meta:set_int("tube_time", 0)
- meta:set_string("formspec", formspec)
+ meta:set_string("formspec", formspec..form_buttons)
local inv = meta:get_inventory()
inv:set_size("src", input_size)
inv:set_size("dst", 4)
@@ -167,17 +192,38 @@ function technic.register_base_machine(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
after_place_node = data.tube and pipeworks.after_place,
- after_dig_node = technic.machine_after_dig_node
+ after_dig_node = technic.machine_after_dig_node,
+ on_receive_fields = function(pos, formname, fields, sender)
+ local node = minetest.get_node(pos)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+ meta:set_string("formspec", formspec..form_buttons)
+ end,
})
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
description = machine_desc:format(tier),
- tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
- "technic_"..ltier.."_"..machine_name.."_bottom.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_side.png",
- "technic_"..ltier.."_"..machine_name.."_front_active.png"},
+ tiles = {
+ "technic_"..ltier.."_"..machine_name.."_top.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_bottom.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_side.png"..tentry,
+ "technic_"..ltier.."_"..machine_name.."_front_active.png"
+ },
paramtype2 = "facedir",
drop = "technic:"..ltier.."_"..machine_name,
groups = active_groups,
@@ -191,6 +237,25 @@ function technic.register_base_machine(data)
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
technic_disabled_machine_name = "technic:"..ltier.."_"..machine_name,
+ on_receive_fields = function(pos, formname, fields, sender)
+ local node = minetest.get_node(pos)
+ if not pipeworks.may_configure(pos, sender) then return end
+ fs_helpers.on_receive_fields(pos, fields)
+ local meta = minetest.get_meta(pos)
+ local form_buttons = ""
+ if not string.find(node.name, ":lv_") then
+ form_buttons = fs_helpers.cycling_button(
+ meta,
+ pipeworks.button_base,
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..pipeworks.button_label
+ end
+ meta:set_string("formspec", formspec..form_buttons)
+ end,
})
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name, technic.receiver)
diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua
index 8ae4dd4..aa41791 100644
--- a/technic/machines/supply_converter.lua
+++ b/technic/machines/supply_converter.lua
@@ -11,6 +11,8 @@ local digilines_path = minetest.get_modpath("digilines")
local S = technic.getter
+local cable_entry = "^technic_cable_connection_overlay.png"
+
local function set_supply_converter_formspec(meta)
local formspec = "size[5,2.25]"..
"field[0.3,0.5;2,1;power;"..S("Input Power")..";"..meta:get_int("power").."]"
@@ -158,9 +160,14 @@ end
minetest.register_node("technic:supply_converter", {
description = S("Supply Converter"),
- tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png",
- "technic_supply_converter_side.png", "technic_supply_converter_side.png",
- "technic_supply_converter_side.png", "technic_supply_converter_side.png"},
+ tiles = {
+ "technic_supply_converter_tb.png"..cable_entry,
+ "technic_supply_converter_tb.png"..cable_entry,
+ "technic_supply_converter_side.png",
+ "technic_supply_converter_side.png",
+ "technic_supply_converter_side.png",
+ "technic_supply_converter_side.png"
+ },
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
technic_machine=1, technic_all_tiers=1},
connect_sides = {"top", "bottom"},
diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua
index be5f6c0..9c6f32c 100644
--- a/technic/machines/switching_station.lua
+++ b/technic/machines/switching_station.lua
@@ -39,6 +39,8 @@ local digilines_path = minetest.get_modpath("digilines")
local S = technic.getter
+local cable_entry = "^technic_cable_connection_overlay.png"
+
minetest.register_craft({
output = "technic:switching_station",
recipe = {
@@ -57,9 +59,13 @@ end
minetest.register_node("technic:switching_station",{
description = S("Switching Station"),
- tiles = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
- "technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
- "technic_water_mill_top_active.png", "technic_water_mill_top_active.png"},
+ tiles = {
+ "technic_water_mill_top_active.png",
+ "technic_water_mill_top_active.png"..cable_entry,
+ "technic_water_mill_top_active.png",
+ "technic_water_mill_top_active.png",
+ "technic_water_mill_top_active.png",
+ "technic_water_mill_top_active.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_all_tiers=1},
connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
diff --git a/technic/textures/technic_cable_connection_overlay.png b/technic/textures/technic_cable_connection_overlay.png
new file mode 100644
index 0000000..122cad2
--- /dev/null
+++ b/technic/textures/technic_cable_connection_overlay.png
Binary files differ
diff --git a/technic/textures/technic_supply_converter_bottom.png b/technic/textures/technic_supply_converter_bottom.png
index a610660..ca49733 100644
--- a/technic/textures/technic_supply_converter_bottom.png
+++ b/technic/textures/technic_supply_converter_bottom.png
Binary files differ
diff --git a/technic/textures/technic_supply_converter_tb.png b/technic/textures/technic_supply_converter_tb.png
new file mode 100644
index 0000000..053b3d8
--- /dev/null
+++ b/technic/textures/technic_supply_converter_tb.png
Binary files differ
diff --git a/technic/textures/technic_supply_converter_top.png b/technic/textures/technic_supply_converter_top.png
index a610660..d3c20a2 100644
--- a/technic/textures/technic_supply_converter_top.png
+++ b/technic/textures/technic_supply_converter_top.png
Binary files differ
diff --git a/technic_chests/common.lua b/technic_chests/common.lua
index 1241c5e..9a5bc7a 100644
--- a/technic_chests/common.lua
+++ b/technic_chests/common.lua
@@ -1,4 +1,3 @@
-
technic.chests.groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
tubedevice=1, tubedevice_receiver=1}
technic.chests.groups_noinv = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
@@ -13,8 +12,10 @@ technic.chests.tube = {
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- local onestack = stack:peek_item(1)
- return inv:room_for_item("main", onestack)
+ if meta:get_int("splitstacks") == 1 then
+ stack = stack:peek_item(1)
+ end
+ return inv:room_for_item("main",stack)
end,
input_inventory = "main",
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
diff --git a/technic_chests/register.lua b/technic_chests/register.lua
index 6a5b8db..0d5c767 100644
--- a/technic_chests/register.lua
+++ b/technic_chests/register.lua
@@ -1,9 +1,16 @@
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
local pipeworks = rawget(_G, "pipeworks")
+local fs_helpers = rawget(_G, "fs_helpers")
+
+local allow_label = ""
+local tube_entry = ""
+local shift_edit_field = 0
+
if not minetest.get_modpath("pipeworks") then
-- Pipeworks is not installed. Simulate using a dummy table...
pipeworks = {}
+ fs_helpers = {}
local pipeworks_meta = {}
setmetatable(pipeworks, pipeworks_meta)
local dummy = function()
@@ -15,6 +22,12 @@ if not minetest.get_modpath("pipeworks") then
end
pipeworks.after_place = dummy
pipeworks.after_dig = dummy
+ fs_helpers.cycling_button = function() return "" end
+else
+ fs_helpers = pipeworks.fs_helpers
+ allow_label = "label[0.9,0.36;Allow splitting incoming stacks from tubes]"
+ shift_edit_field = 3
+ tube_entry = "^pipeworks_tube_connection_metallic.png"
end
local chest_mark_colors = {
@@ -72,6 +85,16 @@ local function set_formspec(pos, data, page)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local formspec = data.base_formspec
+ formspec = formspec..fs_helpers.cycling_button(
+ meta,
+ "image_button[0,0.35;1,0.6",
+ "splitstacks",
+ {
+ pipeworks.button_off,
+ pipeworks.button_on
+ }
+ )..allow_label
+
if data.autosort then
local status = meta:get_int("autosort")
formspec = formspec.."button["..(data.hileft+2)..","..(data.height+1.1)..";3,0.8;autosort_to_"..(1-status)..";"..S("Auto-sort is %s"):format(status == 1 and S("On") or S("Off")).."]"
@@ -79,13 +102,13 @@ local function set_formspec(pos, data, page)
if data.infotext then
local formspec_infotext = minetest.formspec_escape(meta:get_string("infotext"))
if page == "main" then
- formspec = formspec.."image_button["..(data.hileft+2.1)..",0.1;0.8,0.8;"
+ formspec = formspec.."image_button["..(shift_edit_field+data.hileft+2.1)..",0.1;0.8,0.8;"
.."technic_pencil_icon.png;edit_infotext;]"
- .."label["..(data.hileft+3)..",0;"..formspec_infotext.."]"
+ .."label["..(shift_edit_field+data.hileft+3)..",0;"..formspec_infotext.."]"
elseif page == "edit_infotext" then
- formspec = formspec.."image_button["..(data.hileft+2.1)..",0.1;0.8,0.8;"
+ formspec = formspec.."image_button["..(shift_edit_field+data.hileft+2.1)..",0.1;0.8,0.8;"
.."technic_checkmark_icon.png;save_infotext;]"
- .."field["..(data.hileft+3.3)..",0.2;4.8,1;"
+ .."field["..(shift_edit_field+data.hileft+3.3)..",0.2;4.8,1;"
.."infotext_box;"..S("Edit chest description:")..";"
..formspec_infotext.."]"
end
@@ -169,12 +192,17 @@ local function get_receive_fields(name, data)
local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
check_color_buttons(pos, meta, nn, fields)
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
+
meta:get_inventory():set_size("main", data.width * data.height)
set_formspec(pos, data, page)
end
end
-
function technic.chests:definition(name, data)
local lname = name:lower()
name = S(name)
@@ -211,6 +239,7 @@ function technic.chests:definition(name, data)
"background["..data.hileft..",1;"..data.width..","..data.height..";technic_"..lname.."_chest_inventory.png]"..
"background["..data.loleft..","..data.lotop..";8,4;technic_main_inventory.png]"..
"listring[]"
+
if data.sort then
data.base_formspec = data.base_formspec.."button["..data.hileft..","..(data.height+1.1)..";1,0.8;sort;"..S("Sort").."]"
end
@@ -239,11 +268,24 @@ function technic.chests:definition(name, data)
desc = S("%s Chest"):format(name)
end
+ local tentry = tube_entry
+ if tube_entry ~= "" then
+ if lname == "wooden" then
+ tentry = "^pipeworks_tube_connection_wooden.png"
+ elseif lname == "mithril" then
+ tentry = "^pipeworks_tube_connection_stony.png"
+ end
+ end
local def = {
description = desc,
- tiles = {"technic_"..lname.."_chest_top.png", "technic_"..lname.."_chest_top.png",
- "technic_"..lname.."_chest_side.png", "technic_"..lname.."_chest_side.png",
- "technic_"..lname.."_chest_side.png", table.concat(front, "^")},
+ tiles = {
+ "technic_"..lname.."_chest_top.png"..tentry,
+ "technic_"..lname.."_chest_top.png"..tentry,
+ "technic_"..lname.."_chest_side.png"..tentry,
+ "technic_"..lname.."_chest_side.png"..tentry,
+ "technic_"..lname.."_chest_side.png"..tentry,
+ table.concat(front, "^")
+ },
paramtype2 = "facedir",
groups = self.groups,
tube = self.tube,