technic/mining_drill.lua

49 lines
1.5 KiB
Lua
Raw Normal View History

2012-09-11 18:47:09 +02:00
mining_drill_max_charge=60000
minetest.register_tool("technic:mining_drill", {
description = "Mining Drill",
inventory_image = "technic_mining_drill.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type=="node" then
item=itemstack:to_table()
2012-10-28 20:03:36 +01:00
if item["metadata"]=="" or item["metadata"]=="0" then return end --tool not charged
charge=tonumber(item["metadata"])
2012-09-11 20:15:12 +02:00
if charge-200>0 then
2012-09-11 18:47:09 +02:00
drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user)
2012-09-11 20:15:12 +02:00
charge =charge-200;
2012-10-28 20:03:36 +01:00
item["metadata"]=tostring(charge)
set_RE_wear(item,charge,mining_drill_max_charge)
2012-09-11 18:47:09 +02:00
itemstack:replace(item)
end
return itemstack
end
end,
})
minetest.register_craft({
output = 'technic:mining_drill',
recipe = {
{'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'technic:red_energy_crystal', 'technic:stainless_steel_ingot'},
{'', 'moreores:copper_ingot', ''},
}
})
function drill_dig_it (pos, player)
local node=minetest.env:get_node(pos)
2012-10-15 22:29:52 +02:00
if node.name == "air" or node.name == "ignore" then return end
2012-09-11 18:47:09 +02:00
if node.name == "default:lava_source" then return end
if node.name == "default:lava_flowing" then return end
if node.name == "default:water_source" then minetest.env:remove_node(pos) return end
if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
2012-10-15 22:29:52 +02:00
2012-10-10 21:13:20 +02:00
minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,})
2012-10-15 22:29:52 +02:00
minetest.node_dig(pos,node,player)
2012-09-11 18:47:09 +02:00
end