summaryrefslogtreecommitdiff
path: root/pipeworks
diff options
context:
space:
mode:
Diffstat (limited to 'pipeworks')
-rw-r--r--pipeworks/item_transport.lua26
-rw-r--r--pipeworks/luaentity.lua4
2 files changed, 11 insertions, 19 deletions
diff --git a/pipeworks/item_transport.lua b/pipeworks/item_transport.lua
index 0764f73..ae32ec2 100644
--- a/pipeworks/item_transport.lua
+++ b/pipeworks/item_transport.lua
@@ -1,8 +1,7 @@
local luaentity = pipeworks.luaentity
-local enable_max_limit = minetest.setting_get("pipeworks_enable_items_per_second_limit")
-local max_tube_limit = minetest.setting_get("pipeworks_items_per_second") or 30
+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_last_times = {}
pipeworks.tube_item_count = {}
function pipeworks.tube_item(pos, item)
@@ -82,21 +81,19 @@ local function go_next(pos, velocity, stack)
end
end
- local ips_timer = math.floor(pipeworks.items_per_second_timer)
- local h = minetest.hash_node_position(pos)
- 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
+ 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 overpressure ("..k.." items/sec)")
+ 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
- pipeworks.tube_item_count[h] = k + 1
- else
- pipeworks.tube_last_times[h] = ips_timer
- pipeworks.tube_item_count[h] = 1
end
if not next_positions[1] then
@@ -287,7 +284,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
end
else
if minetest.get_item_group(rev_node.name,"tube") == 1 then
- print("[Pipeworks] Warning - tubed item had to reverse direction at "..minetest.pos_to_string(self.start_pos))
velocity = vector.multiply(velocity, -1)
self:setvelocity(velocity)
else
diff --git a/pipeworks/luaentity.lua b/pipeworks/luaentity.lua
index 87a2753..0105c91 100644
--- a/pipeworks/luaentity.lua
+++ b/pipeworks/luaentity.lua
@@ -348,13 +348,9 @@ 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)