summaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua40
1 files changed, 35 insertions, 5 deletions
diff --git a/util.lua b/util.lua
index e32c16b..63903b1 100644
--- a/util.lua
+++ b/util.lua
@@ -52,21 +52,21 @@ digtron.mark_diggable = function(pos, nodes_dug)
local in_known_group = false
local material_cost = 0
- if digtron.creative_mode ~= true then
+ if digtron.config.uses_resources then
if minetest.get_item_group(target.name, "cracky") ~= 0 then
in_known_group = true
- material_cost = math.max(material_cost, digtron.dig_cost_cracky)
+ material_cost = math.max(material_cost, digtron.config.dig_cost_cracky)
end
if minetest.get_item_group(target.name, "crumbly") ~= 0 then
in_known_group = true
- material_cost = math.max(material_cost, digtron.dig_cost_crumbly)
+ material_cost = math.max(material_cost, digtron.config.dig_cost_crumbly)
end
if minetest.get_item_group(target.name, "choppy") ~= 0 then
in_known_group = true
- material_cost = math.max(material_cost, digtron.dig_cost_choppy)
+ material_cost = math.max(material_cost, digtron.config.dig_cost_choppy)
end
if not in_known_group then
- material_cost = digtron.dig_cost_default
+ material_cost = digtron.config.dig_cost_default
end
end
@@ -240,4 +240,34 @@ digtron.is_soft_material = function(target)
return true
end
return false
+end
+
+digtron.show_offset_markers = function(pos, offset, period)
+ local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
+ local x_pos = math.floor((buildpos.x+offset)/period)*period - offset
+ minetest.add_entity({x=x_pos, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ if x_pos >= buildpos.x then
+ minetest.add_entity({x=x_pos - period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ end
+ if x_pos <= buildpos.x then
+ minetest.add_entity({x=x_pos + period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ end
+
+ local y_pos = math.floor((buildpos.y+offset)/period)*period - offset
+ minetest.add_entity({x=buildpos.x, y=y_pos, z=buildpos.z}, "digtron:marker_vertical")
+ if y_pos >= buildpos.y then
+ minetest.add_entity({x=buildpos.x, y=y_pos - period, z=buildpos.z}, "digtron:marker_vertical")
+ end
+ if y_pos <= buildpos.y then
+ minetest.add_entity({x=buildpos.x, y=y_pos + period, z=buildpos.z}, "digtron:marker_vertical")
+ end
+
+ local z_pos = math.floor((buildpos.z+offset)/period)*period - offset
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos}, "digtron:marker"):setyaw(1.5708)
+ if z_pos >= buildpos.z then
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos - period}, "digtron:marker"):setyaw(1.5708)
+ end
+ if z_pos <= buildpos.z then
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker"):setyaw(1.5708)
+ end
end \ No newline at end of file