diff options
author | FaceDeer <FaceDeer@users.noreply.github.com> | 2017-09-30 10:56:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-30 10:56:15 -0600 |
commit | 444411936cc85ba0ef9bfaad11f74544c24cb0b6 (patch) | |
tree | a58d3e8667a8e97e91c2b35e550d58fe3c211611 /util.lua | |
parent | 3441a0d1da37087287fdaade7c8930480abe65e9 (diff) | |
parent | 860890b10061d76c5ea011fe0befca435be5f243 (diff) |
Merge pull request #8 from minetest-mods/cleanup
Cleanup
Diffstat (limited to 'util.lua')
-rw-r--r-- | util.lua | 40 |
1 files changed, 35 insertions, 5 deletions
@@ -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 |