summaryrefslogtreecommitdiff
path: root/pipeworks
diff options
context:
space:
mode:
Diffstat (limited to 'pipeworks')
-rw-r--r--pipeworks/item_transport.lua25
-rw-r--r--pipeworks/luaentity.lua4
-rw-r--r--pipeworks/routing_tubes.lua10
-rw-r--r--pipeworks/textures/pipeworks_broken_tube_end.pngbin0 -> 1545 bytes
-rw-r--r--pipeworks/textures/pipeworks_broken_tube_inv.pngbin0 -> 923 bytes
-rw-r--r--pipeworks/textures/pipeworks_broken_tube_noctr.pngbin0 -> 1581 bytes
-rw-r--r--pipeworks/textures/pipeworks_broken_tube_plain.pngbin0 -> 1803 bytes
-rw-r--r--pipeworks/textures/pipeworks_broken_tube_short.pngbin0 -> 830 bytes
8 files changed, 23 insertions, 16 deletions
diff --git a/pipeworks/item_transport.lua b/pipeworks/item_transport.lua
index 88df0d2..a4c68ea 100644
--- a/pipeworks/item_transport.lua
+++ b/pipeworks/item_transport.lua
@@ -1,5 +1,9 @@
local luaentity = pipeworks.luaentity
-local max_tube_limit = minetest.setting_get("pipeworks_max_tube_limit") or 30
+local enable_max_limit = true minetest.setting_get("pipeworks_enable_items_per_second_limit")
+local max_tube_limit = minetest.setting_get("pipeworks_items_per_second") or 30
+
+pipeworks.tube_last_times = {}
+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")
@@ -32,9 +36,6 @@ function pipeworks.notvel(tbl, vel)
return tbl2
end
-local tube_last_times = {}
-local tube_item_count = {}
-
local function go_next(pos, velocity, stack)
local next_positions = {}
local max_priority = 0
@@ -81,19 +82,21 @@ local function go_next(pos, velocity, stack)
end
end
- local gt = minetest.get_gametime()
+ local ips_timer = math.floor(pipeworks.items_per_second_timer)
local h = minetest.hash_node_position(pos)
- if tube_last_times[h] == gt then
- local k = tube_item_count[h] or 0
- if k > max_tube_limit then
+ if pipeworks.tube_last_times[h] == ips_timer then
+ local k = pipeworks.tube_item_count[h] or 0
+ if enable_max_limit and (k > max_tube_limit) then
-- Kill tube
+ cmeta:set_string("the_tube_was", minetest.serialize(cnode))
+ print("[Pipeworks] Warning - a tube at "..minetest.pos_to_string(pos).." broke due to overpressure ("..k.." items/sec)")
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end
- tube_item_count[h] = k + 1
+ pipeworks.tube_item_count[h] = k + 1
else
- tube_last_times[h] = gt
- tube_item_count[h] = 1
+ pipeworks.tube_last_times[h] = ips_timer
+ pipeworks.tube_item_count[h] = 1
end
if not next_positions[1] then
diff --git a/pipeworks/luaentity.lua b/pipeworks/luaentity.lua
index 0105c91..87a2753 100644
--- a/pipeworks/luaentity.lua
+++ b/pipeworks/luaentity.lua
@@ -348,9 +348,13 @@ end
local handle_active_blocks_step = 0.2
local handle_active_blocks_timer = 0.1
+pipeworks.items_per_second_timer = 0
minetest.register_globalstep(function(dtime)
handle_active_blocks_timer = handle_active_blocks_timer + dtime
+ pipeworks.items_per_second_timer = pipeworks.items_per_second_timer + 0.1
+ -- don't care about overflow in this timer unless you plan to let the game run for 30 years straight :)
+
if handle_active_blocks_timer >= handle_active_blocks_step then
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
move_entities_globalstep_part1(dtime)
diff --git a/pipeworks/routing_tubes.lua b/pipeworks/routing_tubes.lua
index 17a3f79..fa5cefe 100644
--- a/pipeworks/routing_tubes.lua
+++ b/pipeworks/routing_tubes.lua
@@ -1,3 +1,4 @@
+
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
minetest.register_craft( {
@@ -11,11 +12,10 @@ minetest.register_craft( {
pipeworks.register_tube("pipeworks:broken_tube", {
description = "Broken Tube (you hacker you)",
- inventory_image = "pipeworks_tube_broken_inv.png",
- plain = { { name = "pipeworks_tube_broken_plain.png", color = nodecolor, backface_culling = false } },
- noctr = { { name = "pipeworks_tube_broken_plain.png", color = nodecolor, backface_culling = false } },
- ends = { { name = "pipeworks_tube_broken_end.png", color = nodecolor } },
- short = { name = "pipeworks_tube_broken_short.png", color = nodecolor },
+ 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},
diff --git a/pipeworks/textures/pipeworks_broken_tube_end.png b/pipeworks/textures/pipeworks_broken_tube_end.png
new file mode 100644
index 0000000..1829f8c
--- /dev/null
+++ b/pipeworks/textures/pipeworks_broken_tube_end.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_broken_tube_inv.png b/pipeworks/textures/pipeworks_broken_tube_inv.png
new file mode 100644
index 0000000..5b8d707
--- /dev/null
+++ b/pipeworks/textures/pipeworks_broken_tube_inv.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_broken_tube_noctr.png b/pipeworks/textures/pipeworks_broken_tube_noctr.png
new file mode 100644
index 0000000..a17da5f
--- /dev/null
+++ b/pipeworks/textures/pipeworks_broken_tube_noctr.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_broken_tube_plain.png b/pipeworks/textures/pipeworks_broken_tube_plain.png
new file mode 100644
index 0000000..7957e59
--- /dev/null
+++ b/pipeworks/textures/pipeworks_broken_tube_plain.png
Binary files differ
diff --git a/pipeworks/textures/pipeworks_broken_tube_short.png b/pipeworks/textures/pipeworks_broken_tube_short.png
new file mode 100644
index 0000000..237fec5
--- /dev/null
+++ b/pipeworks/textures/pipeworks_broken_tube_short.png
Binary files differ