summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2017-04-05 02:57:22 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-04-05 11:43:41 -0400
commit33c4c9d552c7f113a21405456e67c0e4752674a8 (patch)
tree233642d7c0bf04970da13e9d96e0b16ac6cb5158
parenteab59bfe19209f17892aa87e844990b0b60484b3 (diff)
downloadpipeworks-33c4c9d552c7f113a21405456e67c0e4752674a8.tar
pipeworks-33c4c9d552c7f113a21405456e67c0e4752674a8.tar.gz
pipeworks-33c4c9d552c7f113a21405456e67c0e4752674a8.tar.bz2
pipeworks-33c4c9d552c7f113a21405456e67c0e4752674a8.tar.xz
pipeworks-33c4c9d552c7f113a21405456e67c0e4752674a8.zip
let tubes break if they're "over-pressure"
that is, if there are more than X number of items in a tube. Default is 40 in a tube, but breaking is also disabled by default. (original framework by Novatux, with changes by VanessaE)
-rw-r--r--item_transport.lua19
-rw-r--r--routing_tubes.lua23
-rw-r--r--textures/pipeworks_broken_tube_end.pngbin0 -> 1545 bytes
-rw-r--r--textures/pipeworks_broken_tube_inv.pngbin0 -> 923 bytes
-rw-r--r--textures/pipeworks_broken_tube_noctr.pngbin0 -> 1581 bytes
-rw-r--r--textures/pipeworks_broken_tube_plain.pngbin0 -> 1803 bytes
-rw-r--r--textures/pipeworks_broken_tube_short.pngbin0 -> 830 bytes
7 files changed, 42 insertions, 0 deletions
diff --git a/item_transport.lua b/item_transport.lua
index 12d9e7a..215b65e 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -1,4 +1,8 @@
local luaentity = pipeworks.luaentity
+local enable_max_limit = minetest.setting_get("pipeworks_enable_items_per_tube_limit")
+local max_tube_limit = minetest.setting_get("pipeworks_max_items_per_tube") or 40
+
+pipeworks.tube_item_count = {}
function pipeworks.tube_item(pos, item)
error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
@@ -77,6 +81,21 @@ local function go_next(pos, velocity, stack)
end
end
+ if enable_max_limit then
+ local itemcount = #minetest.get_objects_inside_radius(pos, 0.5)
+
+ local h = minetest.hash_node_position(pos)
+ if itemcount > max_tube_limit then
+ cmeta:set_string("the_tube_was", minetest.serialize(cnode))
+ print("[Pipeworks] Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
+ minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
+ pipeworks.scan_for_tube_objects(pos)
+ pipeworks.tube_item_count[h] = 0
+ else
+ pipeworks.tube_item_count[h] = itemcount
+ end
+ end
+
if not next_positions[1] then
return false, nil
end
diff --git a/routing_tubes.lua b/routing_tubes.lua
index f415c3e..fa5cefe 100644
--- a/routing_tubes.lua
+++ b/routing_tubes.lua
@@ -1,3 +1,4 @@
+
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
minetest.register_craft( {
@@ -9,6 +10,28 @@ minetest.register_craft( {
},
})
+pipeworks.register_tube("pipeworks:broken_tube", {
+ description = "Broken Tube (you hacker you)",
+ plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
+ noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
+ ends = { { name = "pipeworks_broken_tube_end.png", color = nodecolor } },
+ short = { name = "pipeworks_broken_tube_short.png", color = nodecolor },
+ node_def = {
+ drop = "pipeworks:tube_1",
+ groups = {not_in_creative_inventory = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ minetest.item_drop(stack, nil, pos)
+ return ItemStack("")
+ end,
+ can_insert = function(pos,node,stack,direction)
+ return true
+ end,
+ priority = 50,
+ }
+ }
+})
+
-- the high priority tube is a low-cpu replacement for sorting tubes in situations
-- where players would use them for simple routing (turning off paths)
-- without doing actual sorting, like at outputs of tubedevices that might both accept and eject items
diff --git a/textures/pipeworks_broken_tube_end.png b/textures/pipeworks_broken_tube_end.png
new file mode 100644
index 0000000..1829f8c
--- /dev/null
+++ b/textures/pipeworks_broken_tube_end.png
Binary files differ
diff --git a/textures/pipeworks_broken_tube_inv.png b/textures/pipeworks_broken_tube_inv.png
new file mode 100644
index 0000000..5b8d707
--- /dev/null
+++ b/textures/pipeworks_broken_tube_inv.png
Binary files differ
diff --git a/textures/pipeworks_broken_tube_noctr.png b/textures/pipeworks_broken_tube_noctr.png
new file mode 100644
index 0000000..a17da5f
--- /dev/null
+++ b/textures/pipeworks_broken_tube_noctr.png
Binary files differ
diff --git a/textures/pipeworks_broken_tube_plain.png b/textures/pipeworks_broken_tube_plain.png
new file mode 100644
index 0000000..7957e59
--- /dev/null
+++ b/textures/pipeworks_broken_tube_plain.png
Binary files differ
diff --git a/textures/pipeworks_broken_tube_short.png b/textures/pipeworks_broken_tube_short.png
new file mode 100644
index 0000000..237fec5
--- /dev/null
+++ b/textures/pipeworks_broken_tube_short.png
Binary files differ