diff --git a/sparkmachine/lua/quarry.lua b/sparkmachine/lua/quarry.lua index 7a146f9..15efe93 100644 --- a/sparkmachine/lua/quarry.lua +++ b/sparkmachine/lua/quarry.lua @@ -1,11 +1,11 @@ local NAME = minetest.get_current_modname() local ENERGYCOST = { - static_struts = 20, + static_strut = 20, dynamic_struct = 24, hardness_mod = 1, - mining_cost = 40, + mining_cost = 25, } -local FORMSPEC = sparktech.add_inventory(32,8, +local FORMSPEC = sparktech.add_inventory(19.8,8, "list[current_name;quarry;0,0;16,6;]") local MAX_SIZE = 64 @@ -42,7 +42,7 @@ local function on_construct(pos, player) local meta = minetest.get_meta(pos) meta:set_string("formspec", FORMSPEC) local inventory = meta:get_inventory() - inventory:set_size('quarry', 128) + inventory:set_size('quarry', 96) end local function dig_node(pos, quarrypos) @@ -131,10 +131,11 @@ local function clear_area(pos, pos2) return true end -local function place_strut(x, y, z) - local position = Position(x, y, z) +local function place_strut(position, quarrypos) if minetest.get_node(position).name == "air" then - minetest.set_node(position, { name = NAME .. ":static_strut"}) + if try_drain_energy(quarrypos, ENERGYCOST.static_strut) then + minetest.set_node(position, { name = NAME .. ":static_strut"}) + end return true else return false @@ -142,30 +143,30 @@ local function place_strut(x, y, z) end -local function strut_line_x(x, y, z, x2) +local function strut_line_x(x, y, z, x2, quarrypos) local minx, maxx = order(x, x2) for x3=minx, maxx do - if place_strut(x3, y, z) then + if place_strut(Position(x3, y, z), quarrypos) then return false end end return true end -local function strut_line_y(x, y, z, y2) +local function strut_line_y(x, y, z, y2, quarrypos) local miny, maxy = order(y, y2) for y3=miny, maxy do - if place_strut(x, y3, z) then + if place_strut(Position(x, y3, z), quarrypos) then return false end end return true end -local function strut_line_z(x, y, z, z2) +local function strut_line_z(x, y, z, z2, quarrypos) local minz, maxz = order(z, z2) for z3=minz, maxz do - if place_strut(x, y, z3) then + if place_strut(Position(x, y, z3), quarrypos) then return false end end @@ -210,18 +211,18 @@ local function timer_trigger(pos, elapsed) end else minetest.debug("Build strats") - if not strut_line_x(pos.x, pos.y, pos.z, marker_pos.x) then break end - if not strut_line_x(pos.x, marker_pos.y, pos.z, marker_pos.x) then break end - if not strut_line_x(pos.x, pos.y, marker_pos.z, marker_pos.x) then break end - if not strut_line_x(pos.x, marker_pos.y, marker_pos.z, marker_pos.x) then break end - if not strut_line_z(pos.x, pos.y, pos.z, marker_pos.z) then break end - if not strut_line_z(marker_pos.x, pos.y, pos.z, marker_pos.z) then break end - if not strut_line_z(pos.x, marker_pos.y, pos.z, marker_pos.z) then break end - if not strut_line_z(marker_pos.x, marker_pos.y, pos.z, marker_pos.z) then break end - if not strut_line_y(marker_pos.x, pos.y, marker_pos.z, marker_pos.y) then break end - if not strut_line_y(pos.x, pos.y, marker_pos.z, marker_pos.y) then break end - if not strut_line_y(marker_pos.x, pos.y, pos.z, marker_pos.y) then break end - if not strut_line_y(pos.x, pos.y, pos.z, marker_pos.y) then break end + if not strut_line_x(pos.x, pos.y, pos.z, marker_pos.x, pos) then break end + if not strut_line_x(pos.x, marker_pos.y, pos.z, marker_pos.x, pos) then break end + if not strut_line_x(pos.x, pos.y, marker_pos.z, marker_pos.x, pos) then break end + if not strut_line_x(pos.x, marker_pos.y, marker_pos.z, marker_pos.x, pos) then break end + if not strut_line_z(pos.x, pos.y, pos.z, marker_pos.z, pos) then break end + if not strut_line_z(marker_pos.x, pos.y, pos.z, marker_pos.z, pos) then break end + if not strut_line_z(pos.x, marker_pos.y, pos.z, marker_pos.z, pos) then break end + if not strut_line_z(marker_pos.x, marker_pos.y, pos.z, marker_pos.z, pos) then break end + if not strut_line_y(marker_pos.x, pos.y, marker_pos.z, marker_pos.y, pos) then break end + if not strut_line_y(pos.x, pos.y, marker_pos.z, marker_pos.y, pos) then break end + if not strut_line_y(marker_pos.x, pos.y, pos.z, marker_pos.y, pos) then break end + if not strut_line_y(pos.x, pos.y, pos.z, marker_pos.y, pos) then break end --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) @@ -242,7 +243,7 @@ local function timer_trigger(pos, elapsed) meta:set_int("current_frame", framenum) - if framenum > -MAX_SIZE then minetest.get_node_timer(pos):start(0.1) end + if framenum >= -MAX_SIZE then minetest.get_node_timer(pos):start(0.1) end end minetest.register_node( NAME .. ":quarry_marker", {