From 29c7ff5228864bcf5456f391b122c9eb477c754b Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz <vanessaezekowitz@gmail.com> Date: Wed, 23 Jul 2014 16:00:13 +0200 Subject: [PATCH] don't attempt to force-load blocks if they're already loaded. --- technic/machines/HV/quarry.lua | 70 ++++++++++++++++------------------- 1 files changed, 32 insertions(+), 38 deletions(-) diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index a8c37bc..628c443 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -126,13 +126,43 @@ end end +local run = function(pos, node) + local meta = minetest.get_meta(pos) + local size = meta:get_int("size") + local eu_input = meta:get_int("HV_EU_input") + local demand = 10000 + local center = get_quarry_center(pos, size) + local dig_y = meta:get_int("dig_y") + local machine_name = S("%s Quarry"):format("HV") + + if meta:get_int("enabled") == 0 then + meta:set_string("infotext", S("%s Disabled"):format(machine_name)) + meta:set_int("HV_EU_demand", 0) + return + end + + if eu_input < demand then + meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) + elseif eu_input >= demand then + meta:set_string("infotext", S("%s Active"):format(machine_name)) + + local items = quarry_dig(pos, center, size) + send_items(items, pos, node) + + if dig_y < pos.y - quarry_max_depth then + meta:set_string("infotext", S("%s Finished"):format(machine_name)) + end + end + meta:set_int("HV_EU_demand", demand) +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"}, paramtype2 = "facedir", - groups = {cracky=2, tubedevice=1}, + groups = {cracky=2, tubedevice=1, technic_machine = 1}, tube = { connect_sides = {top = 1}, }, @@ -150,43 +180,7 @@ end, after_dig_node = pipeworks.scan_for_tube_objects, on_receive_fields = quarry_receive_fields, -}) - -minetest.register_abm({ - nodenames = {"technic:quarry"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.get_meta(pos) - local size = meta:get_int("size") - local eu_input = meta:get_int("HV_EU_input") - local demand = 10000 - local center = get_quarry_center(pos, size) - local dig_y = meta:get_int("dig_y") - local machine_name = S("%s Quarry"):format("HV") - - technic.switching_station_timeout_count(pos, "HV") - - if meta:get_int("enabled") == 0 then - meta:set_string("infotext", S("%s Disabled"):format(machine_name)) - meta:set_int("HV_EU_demand", 0) - return - end - - if eu_input < demand then - meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) - elseif eu_input >= demand then - meta:set_string("infotext", S("%s Active"):format(machine_name)) - - local items = quarry_dig(pos, center, size) - send_items(items, pos, node) - - if dig_y < pos.y - quarry_max_depth then - meta:set_string("infotext", S("%s Finished"):format(machine_name)) - end - end - meta:set_int("HV_EU_demand", demand) - end + technic_run = run, }) technic.register_machine("HV", "technic:quarry", technic.receiver) -- Gitblit v1.8.0