diff options
author | Maciej Kasatkin <mk@realbadangel.pl> | 2012-09-11 18:47:09 +0200 |
---|---|---|
committer | Maciej Kasatkin <mk@realbadangel.pl> | 2012-09-11 18:47:09 +0200 |
commit | 582f94952a706f8d03ecfb7ba79fe84a66c4c871 (patch) | |
tree | 43ed880efa5107fb7f9e91a730adfbe91f9bb8c5 /mining_drill.lua | |
parent | f42c9b68c3ac1601e983f09ebb5b2dcec356340d (diff) |
Added Mining Drill
Diffstat (limited to 'mining_drill.lua')
-rw-r--r-- | mining_drill.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mining_drill.lua b/mining_drill.lua new file mode 100644 index 0000000..78c11a4 --- /dev/null +++ b/mining_drill.lua @@ -0,0 +1,60 @@ +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() + local charge=tonumber((item["wear"])) + if charge ==0 then charge =65535 end + if charge ==65535 then charge =1 end + charge=get_RE_item_load(charge,laser_mk1_max_charge) + if charge-400>0 then + drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user) + charge =charge-400; + charge=set_RE_item_load(charge,laser_mk1_max_charge) + item["wear"]=tostring(charge) + 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) + if node.name == "air" then return end + 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 + if node.name == "ignore" then minetest.env:remove_node(pos) return end + + if player then + local drops = minetest.get_node_drops(node.name, "default:pick_mese") + if player:get_inventory() then + local _, dropped_item + for _, dropped_item in ipairs(drops) do + player:get_inventory():add_item("main", dropped_item) + end + end + minetest.env:remove_node(pos) + end + +end
\ No newline at end of file |