From 2e7859c35e55b842752c6533edae2dd19290fabc Mon Sep 17 00:00:00 2001 From: Tanmaya Meher <tanmayameher@users.noreply.github.com> Date: Sat, 25 Aug 2018 12:24:14 +0200 Subject: [PATCH] New MV Hydro Machine (#412) --- technic/machines/HV/quarry.lua | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 37 insertions(+), 16 deletions(-) diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index ed16042..86ca395 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -1,17 +1,21 @@ local S = technic.getter +local tube_entry = "^pipeworks_tube_connection_metallic.png" +local cable_entry = "^technic_cable_connection_overlay.png" + minetest.register_craft({ recipe = { {"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"}, {"technic:motor", "technic:machine_casing", "technic:diamond_drill_head"}, - {"technic:carbon_steel_block", "technic:hv_cable0", "technic:carbon_steel_block"}}, + {"technic:carbon_steel_block", "technic:hv_cable", "technic:carbon_steel_block"}}, output = "technic:quarry", }) local quarry_dig_above_nodes = 3 -- How far above the quarry we will dig nodes local quarry_max_depth = 100 local quarry_demand = 10000 +local quarry_eject_dir = vector.new(0, 1, 0) local function set_quarry_formspec(meta) local radius = meta:get_int("size") @@ -83,7 +87,7 @@ if stack then local item = stack:to_table() if item then - technic.tube_inject_item(pos, pos, vector.new(0, 1, 0), item) + technic.tube_inject_item(pos, pos, quarry_eject_dir, item) stack:clear() inv:set_stack("cache", i, stack) break @@ -118,15 +122,6 @@ vector.new(0, quarry_dig_above_nodes, 0)), pdir), vector.multiply(qdir, -radius)) - local endpos = vector.add(vector.add(vector.add(startpos, - vector.new(0, -quarry_dig_above_nodes-quarry_max_depth, 0)), - vector.multiply(pdir, diameter-1)), - vector.multiply(qdir, diameter-1)) - local vm = VoxelManip() - local minpos, maxpos = vm:read_from_map(startpos, endpos) - local area = VoxelArea:new({MinEdge=minpos, MaxEdge=maxpos}) - local data = vm:get_data() - local c_air = minetest.get_content_id("air") local owner = meta:get_string("owner") local nd = meta:get_int("dug") while nd ~= diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) do @@ -150,7 +145,17 @@ if can_dig then dignode = technic.get_or_load_node(digpos) or minetest.get_node(digpos) local dignodedef = minetest.registered_nodes[dignode.name] or {diggable=false} - if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, nil)) then + -- doors mod among other thing does NOT like a nil digger... + local fakedigger = { + get_player_name = function() + return "!technic_quarry_fake_digger" + end, + is_player = function() return false end, + get_wielded_item = function() + return ItemStack("air") + end, + } + if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, fakedigger)) then can_dig = false end end @@ -206,13 +211,29 @@ 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"}, + tiles = { + "technic_carbon_steel_block.png"..tube_entry, + "technic_carbon_steel_block.png"..cable_entry, + "technic_carbon_steel_block.png"..cable_entry, + "technic_carbon_steel_block.png"..cable_entry, + "technic_carbon_steel_block.png^default_tool_mesepick.png", + "technic_carbon_steel_block.png"..cable_entry + }, paramtype2 = "facedir", - groups = {cracky=2, tubedevice=1, technic_machine = 1}, + groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1}, + connect_sides = {"bottom", "front", "left", "right"}, tube = { connect_sides = {top = 1}, + -- lower priority than other tubes, so that quarries will prefer any + -- other tube to another quarry, which could lead to server freezes + -- in certain quarry placements (2x2 for example would never eject) + priority = 10, + can_go = function(pos, node, velocity, stack) + -- always eject the same, even if items came in another way + -- this further mitigates loops and generally avoids random sideway movement + -- that can be expected in certain quarry placements + return { quarry_eject_dir } + end }, on_construct = function(pos) local meta = minetest.get_meta(pos) -- Gitblit v1.8.0