2013-07-17 15:34:35 -04:00
|
|
|
|
2013-10-30 13:45:32 -04:00
|
|
|
local S = technic.getter
|
|
|
|
|
2013-07-17 15:34:35 -04:00
|
|
|
minetest.register_craft({
|
|
|
|
recipe = {
|
2014-07-07 21:48:38 +01:00
|
|
|
{"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"},
|
2014-07-06 18:45:16 +01:00
|
|
|
{"technic:motor", "technic:machine_casing", "technic:diamond_drill_head"},
|
|
|
|
{"technic:carbon_steel_block", "technic:hv_cable0", "technic:carbon_steel_block"}},
|
2013-07-17 15:34:35 -04:00
|
|
|
output = "technic:quarry",
|
|
|
|
})
|
|
|
|
|
|
|
|
local quarry_dig_above_nodes = 3 -- How far above the quarry we will dig nodes
|
|
|
|
local quarry_max_depth = 100
|
|
|
|
|
2014-05-23 22:37:44 +01:00
|
|
|
local function set_quarry_formspec(meta)
|
|
|
|
local formspec = "size[3,1.5]"..
|
|
|
|
"field[1,0.5;2,1;size;Radius;"..meta:get_int("size").."]"
|
|
|
|
if meta:get_int("enabled") == 0 then
|
Rationalise machine terminology
All electrically-powered machines now consistently indicate their
tier (supply voltage) in their names. As this implies that they are
electrically powered, the furnaces no longer have "Electric" in their
names. The fuel-fired equivalents of electric machines, which exist
for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them.
(The fuel-fired alloy furnace used to say "Coal", which was inaccurate
because it uses any fuel. The fuel-fired furnace, from the default mod,
used to just be called "Furnace", which is ambiguous.)
Electric power generators now consistently indicate their tier and have
the word "Generator" in their names. This makes their purpose much
clearer, and makes obvious craft guide searches produce useful results.
The fuel-fired generators, previously just (ambiguously) called
"Generator", are now explicitly "Fuel-Fired".
2014-06-20 16:58:52 +01:00
|
|
|
formspec = formspec.."button[0,1;3,1;enable;"..S("%s Disabled"):format(S("%s Quarry"):format("HV")).."]"
|
2014-05-23 22:37:44 +01:00
|
|
|
else
|
Rationalise machine terminology
All electrically-powered machines now consistently indicate their
tier (supply voltage) in their names. As this implies that they are
electrically powered, the furnaces no longer have "Electric" in their
names. The fuel-fired equivalents of electric machines, which exist
for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them.
(The fuel-fired alloy furnace used to say "Coal", which was inaccurate
because it uses any fuel. The fuel-fired furnace, from the default mod,
used to just be called "Furnace", which is ambiguous.)
Electric power generators now consistently indicate their tier and have
the word "Generator" in their names. This makes their purpose much
clearer, and makes obvious craft guide searches produce useful results.
The fuel-fired generators, previously just (ambiguously) called
"Generator", are now explicitly "Fuel-Fired".
2014-06-20 16:58:52 +01:00
|
|
|
formspec = formspec.."button[0,1;3,1;disable;"..S("%s Enabled"):format(S("%s Quarry"):format("HV")).."]"
|
2014-05-23 22:37:44 +01:00
|
|
|
end
|
|
|
|
meta:set_string("formspec", formspec)
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
local function quarry_receive_fields(pos, formname, fields, sender)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2014-05-23 22:37:44 +01:00
|
|
|
if fields.size then
|
|
|
|
local size = tonumber(fields.size) or 0
|
|
|
|
size = math.max(size, 2)
|
|
|
|
size = math.min(size, 8)
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_int("size", size)
|
|
|
|
end
|
2014-05-23 22:37:44 +01:00
|
|
|
if fields.enable then meta:set_int("enabled", 1) end
|
|
|
|
if fields.disable then meta:set_int("enabled", 0) end
|
|
|
|
set_quarry_formspec(meta)
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
local function get_quarry_center(pos, size)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local back_dir = minetest.facedir_to_dir(node.param2)
|
|
|
|
local relative_center = vector.multiply(back_dir, size + 1)
|
|
|
|
local center = vector.add(pos, relative_center)
|
|
|
|
return center
|
|
|
|
end
|
|
|
|
|
|
|
|
local function gen_next_digpos(center, digpos, size)
|
|
|
|
digpos.x = digpos.x + 1
|
|
|
|
if digpos.x > center.x + size then
|
|
|
|
digpos.x = center.x - size
|
|
|
|
digpos.z = digpos.z + 1
|
|
|
|
end
|
|
|
|
if digpos.z > center.z + size then
|
|
|
|
digpos.x = center.x - size
|
|
|
|
digpos.z = center.z - size
|
|
|
|
digpos.y = digpos.y - 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function find_next_digpos(data, area, center, dig_y, size)
|
|
|
|
local c_air = minetest.get_content_id("air")
|
|
|
|
|
|
|
|
for y = center.y + quarry_dig_above_nodes, dig_y - 1, -1 do
|
|
|
|
for z = center.z - size, center.z + size do
|
|
|
|
for x = center.x - size, center.x + size do
|
|
|
|
if data[area:index(x, y, z)] ~= c_air then
|
|
|
|
return vector.new(x, y, z)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function quarry_dig(pos, center, size)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local drops = {}
|
|
|
|
local dig_y = meta:get_int("dig_y")
|
2013-12-29 10:59:04 -05:00
|
|
|
local owner = meta:get_string("owner")
|
2013-07-17 15:34:35 -04:00
|
|
|
|
|
|
|
local vm = VoxelManip()
|
|
|
|
local p1 = vector.new(
|
|
|
|
center.x - size,
|
|
|
|
center.y + quarry_dig_above_nodes,
|
|
|
|
center.z - size)
|
|
|
|
local p2 = vector.new(
|
|
|
|
center.x + size,
|
|
|
|
dig_y - 1, -- One node lower in case we have finished the current layer
|
|
|
|
center.z + size)
|
|
|
|
local e1, e2 = vm:read_from_map(p1, p2)
|
|
|
|
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
|
|
|
|
local data = vm:get_data()
|
|
|
|
|
|
|
|
local digpos = find_next_digpos(data, area, center, dig_y, size)
|
|
|
|
|
|
|
|
if digpos then
|
|
|
|
if digpos.y < pos.y - quarry_max_depth then
|
|
|
|
meta:set_int("dig_y", digpos.y)
|
|
|
|
return drops
|
|
|
|
end
|
|
|
|
if minetest.is_protected and minetest.is_protected(digpos, owner) then
|
|
|
|
meta:set_int("enabled", 0)
|
2014-05-23 22:37:44 +01:00
|
|
|
set_quarry_formspec(meta)
|
2013-11-18 15:27:17 -05:00
|
|
|
return {}
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
dig_y = digpos.y
|
|
|
|
local node = minetest.get_node(digpos)
|
2014-05-18 21:03:58 +01:00
|
|
|
local node_def = minetest.registered_nodes[node.name] or { diggable = false }
|
|
|
|
if node_def.diggable and ((not node_def.can_dig) or node_def.can_dig(digpos, nil)) then
|
|
|
|
minetest.remove_node(digpos)
|
|
|
|
drops = minetest.get_node_drops(node.name, "")
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
elseif not (dig_y < pos.y - quarry_max_depth) then
|
|
|
|
dig_y = dig_y - 16
|
|
|
|
end
|
|
|
|
|
|
|
|
meta:set_int("dig_y", dig_y)
|
|
|
|
return drops
|
|
|
|
end
|
|
|
|
|
|
|
|
local function send_items(items, pos, node)
|
|
|
|
for _, item in pairs(items) do
|
2013-12-15 15:03:41 -05:00
|
|
|
local tube_item = pipeworks.tube_item(vector.new(pos), item)
|
2013-07-17 15:34:35 -04:00
|
|
|
tube_item:get_luaentity().start_pos = vector.new(pos)
|
|
|
|
tube_item:setvelocity(vector.new(0, 1, 0))
|
|
|
|
tube_item:setacceleration({x=0, y=0, z=0})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-11 11:00:46 +02:00
|
|
|
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
|
|
|
|
|
2013-07-17 15:34:35 -04:00
|
|
|
minetest.register_node("technic:quarry", {
|
Rationalise machine terminology
All electrically-powered machines now consistently indicate their
tier (supply voltage) in their names. As this implies that they are
electrically powered, the furnaces no longer have "Electric" in their
names. The fuel-fired equivalents of electric machines, which exist
for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them.
(The fuel-fired alloy furnace used to say "Coal", which was inaccurate
because it uses any fuel. The fuel-fired furnace, from the default mod,
used to just be called "Furnace", which is ambiguous.)
Electric power generators now consistently indicate their tier and have
the word "Generator" in their names. This makes their purpose much
clearer, and makes obvious craft guide searches produce useful results.
The fuel-fired generators, previously just (ambiguously) called
"Generator", are now explicitly "Fuel-Fired".
2014-06-20 16:58:52 +01:00
|
|
|
description = S("%s Quarry"):format("HV"),
|
split default iron/steel into three metals
Override the default mod's iron/steel substance, replacing it with three
metals: wrought iron (pure iron), carbon steel (iron alloyed with a little
carbon), and cast iron (iron alloyed with lots of carbon). Wrought iron
is easiest to refine, then cast iron, and carbon steel the most difficult,
matching the historical progression. Recipes that used default steel are
changed to use one of the three, the choice of alloy for each application
being both somewhat realistic and also matching up with game progression.
The default:steel{_ingot,block} items are identified specifically with
wrought iron. This makes the default refining recipes work appropriately.
Iron-using recipes defined outside technic are thus necessarily
reinterpreted to use wrought iron, which is mostly appropriate.
Some objects are renamed accordingly.
Rather than use the default steel textures for wrought iron, with technic
providing textures for the other two, technic now provides textures for
all three metals. This avoids problems that would occur with texture
packs that provide default_steel_{ingot,block} textures that are not
intended to support this wrought-iron/carbon-steel/cast-iron distinction.
A texture pack can provide a distinct set of three textures specifically
for the situation where this distinction is required.
Incidentally make grinding and alloy cooking recipes work correctly when
ingredients are specified by alias.
2014-05-16 22:02:49 +01:00
|
|
|
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"},
|
2013-07-17 15:34:35 -04:00
|
|
|
paramtype2 = "facedir",
|
2014-07-11 11:00:46 +02:00
|
|
|
groups = {cracky=2, tubedevice=1, technic_machine = 1},
|
2013-07-17 15:34:35 -04:00
|
|
|
tube = {
|
|
|
|
connect_sides = {top = 1},
|
|
|
|
},
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
Rationalise machine terminology
All electrically-powered machines now consistently indicate their
tier (supply voltage) in their names. As this implies that they are
electrically powered, the furnaces no longer have "Electric" in their
names. The fuel-fired equivalents of electric machines, which exist
for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them.
(The fuel-fired alloy furnace used to say "Coal", which was inaccurate
because it uses any fuel. The fuel-fired furnace, from the default mod,
used to just be called "Furnace", which is ambiguous.)
Electric power generators now consistently indicate their tier and have
the word "Generator" in their names. This makes their purpose much
clearer, and makes obvious craft guide searches produce useful results.
The fuel-fired generators, previously just (ambiguously) called
"Generator", are now explicitly "Fuel-Fired".
2014-06-20 16:58:52 +01:00
|
|
|
meta:set_string("infotext", S("%s Quarry"):format("HV"))
|
2014-05-23 22:37:44 +01:00
|
|
|
meta:set_int("size", 4)
|
|
|
|
set_quarry_formspec(meta)
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_int("dig_y", pos.y)
|
|
|
|
end,
|
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("owner", placer:get_player_name())
|
2013-12-15 15:49:28 -05:00
|
|
|
pipeworks.scan_for_tube_objects(pos)
|
2013-07-17 15:34:35 -04:00
|
|
|
end,
|
2013-12-15 15:49:28 -05:00
|
|
|
after_dig_node = pipeworks.scan_for_tube_objects,
|
2013-07-17 15:34:35 -04:00
|
|
|
on_receive_fields = quarry_receive_fields,
|
2014-07-11 11:00:46 +02:00
|
|
|
technic_run = run,
|
2013-07-17 15:34:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
technic.register_machine("HV", "technic:quarry", technic.receiver)
|
|
|
|
|