From c8b103938b3dbe607794f9418d509c0c6377e42a Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Wed, 5 Apr 2017 03:40:16 -0400 Subject: update pipeworks --- pipeworks/item_transport.lua | 25 ++++++++++++--------- pipeworks/luaentity.lua | 4 ++++ pipeworks/routing_tubes.lua | 10 ++++----- pipeworks/textures/pipeworks_broken_tube_end.png | Bin 0 -> 1545 bytes pipeworks/textures/pipeworks_broken_tube_inv.png | Bin 0 -> 923 bytes pipeworks/textures/pipeworks_broken_tube_noctr.png | Bin 0 -> 1581 bytes pipeworks/textures/pipeworks_broken_tube_plain.png | Bin 0 -> 1803 bytes pipeworks/textures/pipeworks_broken_tube_short.png | Bin 0 -> 830 bytes 8 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 pipeworks/textures/pipeworks_broken_tube_end.png create mode 100644 pipeworks/textures/pipeworks_broken_tube_inv.png create mode 100644 pipeworks/textures/pipeworks_broken_tube_noctr.png create mode 100644 pipeworks/textures/pipeworks_broken_tube_plain.png create mode 100644 pipeworks/textures/pipeworks_broken_tube_short.png (limited to 'pipeworks') 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 Binary files /dev/null and b/pipeworks/textures/pipeworks_broken_tube_end.png 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 Binary files /dev/null and b/pipeworks/textures/pipeworks_broken_tube_inv.png 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 Binary files /dev/null and b/pipeworks/textures/pipeworks_broken_tube_noctr.png 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 Binary files /dev/null and b/pipeworks/textures/pipeworks_broken_tube_plain.png 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 Binary files /dev/null and b/pipeworks/textures/pipeworks_broken_tube_short.png differ -- cgit v1.2.3