|
|
|
@ -4,10 +4,32 @@ local ENERGYCOST = {
|
|
|
|
|
dynamic_struct = 24,
|
|
|
|
|
hardness_mod = 1
|
|
|
|
|
}
|
|
|
|
|
local FORMSPEC = sparktech.add_inventory(32,8,
|
|
|
|
|
"list[current_name;quarry;0,0;32,4;]")
|
|
|
|
|
|
|
|
|
|
local function on_construct(pos, player)
|
|
|
|
|
player:get_meta():set_string(NAME .. ":quarry_pos" , minetest.pos_to_string(pos))
|
|
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
|
meta:set_string("formspec", FORMSPEC)
|
|
|
|
|
local inventory = meta:get_inventory()
|
|
|
|
|
inventory:set_size('quarry', 128)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function dig_node(pos, quarrypos)
|
|
|
|
|
--[[ local node = minetest.get_node(pos)
|
|
|
|
|
local quarryinv = minetest.get_meta(pos):get_inventory()
|
|
|
|
|
minetest.debug(ItemStack(node.name):get_name())
|
|
|
|
|
local itemstack = ItemStack(nil)
|
|
|
|
|
itemstack:add_item(node.name)
|
|
|
|
|
minetest.debug(itemstack:to_string())
|
|
|
|
|
if quarryinv:room_for_item("quarry", itemstack) then
|
|
|
|
|
quarryinv:add_item("quarry", itemstack) ]]--
|
|
|
|
|
--
|
|
|
|
|
-- Pretend this puts items in the quarry inventory, okay?
|
|
|
|
|
minetest.set_node(pos, {name = "air"})
|
|
|
|
|
--end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function on_marker_placed(pos, quarry_pos, player)
|
|
|
|
@ -55,7 +77,7 @@ local function clear_area(pos, pos2)
|
|
|
|
|
if not ((x == pos.x and y == pos.y and z == pos.z) or
|
|
|
|
|
(x == pos2.x and y == pos2.y and z == pos2.z))
|
|
|
|
|
then
|
|
|
|
|
minetest.dig_node({ x=x, y=y, z=z })
|
|
|
|
|
dig_node({x=x, y=y, z=z}, pos)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -72,27 +94,21 @@ end
|
|
|
|
|
|
|
|
|
|
local function strut_line_x(x, y, z, x2)
|
|
|
|
|
local minx, maxx = order(x, x2)
|
|
|
|
|
minetest.debug(" x:" .. minx .. ":" .. maxx)
|
|
|
|
|
for x3=minx, maxx do
|
|
|
|
|
minetest.debug("x")
|
|
|
|
|
place_strut(x3, y, z)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function strut_line_y(x, y, z, y2)
|
|
|
|
|
local miny, maxy = order(y, y2)
|
|
|
|
|
minetest.debug(" y:" .. miny .. ":" .. maxy)
|
|
|
|
|
for y3=miny, maxy do
|
|
|
|
|
minetest.debug("y")
|
|
|
|
|
place_strut(x, y3, z)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function strut_line_z(x, y, z, z2)
|
|
|
|
|
local minz, maxz = order(z, z2)
|
|
|
|
|
minetest.debug(" z:" .. minz .. ":" .. maxz)
|
|
|
|
|
for z3=minz, maxz do
|
|
|
|
|
minetest.debug("z")
|
|
|
|
|
place_strut(x, y, z3)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -105,6 +121,16 @@ local function timer_trigger(pos, elapsed)
|
|
|
|
|
framenum = 13
|
|
|
|
|
end
|
|
|
|
|
if framenum < 0 then
|
|
|
|
|
local start_pos = minetest.string_to_pos(meta:get_string("dig_area_start"))
|
|
|
|
|
local end_pos = minetest.string_to_pos(meta:get_string("dig_area_end"))
|
|
|
|
|
if not start_pos or not end_pos then return end
|
|
|
|
|
local height = start_pos.y + framenum
|
|
|
|
|
minetest.debug(start_pos.y .. ": " .. height)
|
|
|
|
|
for x=start_pos.x, end_pos.x do
|
|
|
|
|
for z=start_pos.z, end_pos.z do
|
|
|
|
|
dig_node({x, height, z}, pos)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- Operation Phase
|
|
|
|
|
--
|
|
|
|
|
else
|
|
|
|
@ -137,8 +163,18 @@ local function timer_trigger(pos, elapsed)
|
|
|
|
|
strut_line_y(pos.x, pos.y, pos.z, marker_pos.y)
|
|
|
|
|
elseif framenum == 0 then
|
|
|
|
|
--shrink the operational area here to a 2d space with one piece of border taken away to drill there
|
|
|
|
|
local posx, pos2x = order(pos.x, marker_pos.x)
|
|
|
|
|
local posy, pos2y = order(pos.y, marker_pos.y)
|
|
|
|
|
local posz, pos2z = order(pos.z, marker_pos.z)
|
|
|
|
|
posx = posx +1
|
|
|
|
|
pos2x = pos2x -1
|
|
|
|
|
posy = posy + 1
|
|
|
|
|
pos2y = pos2y -1
|
|
|
|
|
meta:set_string("dig_area_start", minetest.pos_to_string({ x= posx, y= posy, z= posz}))
|
|
|
|
|
meta:set_string("dig_area_end", minetest.pos_to_string({ x= pos2x, y= posy, z= pos2z})) -- can use this last z as counter, or ignore it
|
|
|
|
|
minetest.debug("setup complete")
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
minetest.debug(framenum)
|
|
|
|
|
end
|
|
|
|
|
meta:set_int("current_frame", framenum -1)
|
|
|
|
|
|
|
|
|
@ -210,6 +246,6 @@ minetest.register_node( NAME .. ":lv_quarry", {
|
|
|
|
|
after_place_node = on_construct,
|
|
|
|
|
|
|
|
|
|
--on_destruct = function(pos, player) player:get_meta():set_string(NAME .. ":quarry_pos" , "") end,
|
|
|
|
|
allow_metadata_inventory_put = function() return false end,
|
|
|
|
|
allow_metadata_inventory_put = function(_,_,_, stack) return stacK:get_count() end,
|
|
|
|
|
allow_metadata_inventory_take = function(_, _, _, stack) return stack:get_count() end
|
|
|
|
|
})
|
|
|
|
|