Zefram
2014-07-07 5e4a87b92599aa0fc9a56081209c930d08a2c3bd
technic/tools/mining_drill.lua
@@ -6,7 +6,7 @@
minetest.register_craft({
   output = 'technic:mining_drill',
   recipe = {
      {'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
      {'moreores:tin_ingot',            'technic:diamond_drill_head', 'moreores:tin_ingot'},
      {'technic:stainless_steel_ingot', 'technic:motor',              'technic:stainless_steel_ingot'},
      {'',                              'technic:red_energy_crystal', 'moreores:copper_ingot'},
   }
@@ -229,6 +229,12 @@
   minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,})
end
local function pos_is_pointable(pos)
   local node = minetest.env:get_node(pos)
   local nodedef = minetest.registered_nodes[node.name]
   return nodedef and nodedef.pointable
end
local function mining_drill_mk2_setmode(user,itemstack)
   local player_name=user:get_player_name()
   local item=itemstack:to_table()
@@ -285,7 +291,7 @@
   if not meta or not meta.mode or keys.sneak then
      return mining_drill_mk2_setmode(user, itemstack)
   end
   if pointed_thing.type ~= "node" or not meta.charge then
   if pointed_thing.type ~= "node" or not pos_is_pointable(pointed_thing.under) or not meta.charge then
      return
   end
   local charge_to_take = cost_to_use(2, meta.mode)
@@ -306,7 +312,7 @@
   if not meta or not meta.mode or keys.sneak then
      return mining_drill_mk3_setmode(user, itemstack)
   end
   if pointed_thing.type ~= "node" or not meta.charge then
   if pointed_thing.type ~= "node" or not pos_is_pointable(pointed_thing.under) or not meta.charge then
      return
   end
   local charge_to_take = cost_to_use(3, meta.mode)
@@ -326,8 +332,10 @@
   description = S("Mining Drill Mk%d"):format(1),
   inventory_image = "technic_mining_drill.png",
   stack_max = 1,
   wear_represents = "technic_RE_charge",
   on_refill = technic.refill_RE_charge,
   on_use = function(itemstack, user, pointed_thing)
      if pointed_thing.type ~= "node" then
      if pointed_thing.type ~= "node" or not pos_is_pointable(pointed_thing.under) then
         return itemstack
      end
      local meta = minetest.deserialize(itemstack:get_metadata())
@@ -349,6 +357,8 @@
minetest.register_tool("technic:mining_drill_mk2", {
   description = S("Mining Drill Mk%d"):format(2),
   inventory_image = "technic_mining_drill_mk2.png",
   wear_represents = "technic_RE_charge",
   on_refill = technic.refill_RE_charge,
   on_use = function(itemstack, user, pointed_thing)
      mining_drill_mk2_handler(itemstack, user, pointed_thing)
      return itemstack
@@ -363,6 +373,8 @@
      description = S("Mining Drill Mk%d Mode %d"):format(2, i),
      inventory_image = "technic_mining_drill_mk2.png^technic_tool_mode"..i..".png",
      wield_image = "technic_mining_drill_mk2.png",
      wear_represents = "technic_RE_charge",
      on_refill = technic.refill_RE_charge,
      groups = {not_in_creative_inventory=1},
      on_use = function(itemstack, user, pointed_thing)
         mining_drill_mk2_handler(itemstack, user, pointed_thing)
@@ -374,6 +386,8 @@
minetest.register_tool("technic:mining_drill_mk3", {
   description = S("Mining Drill Mk%d"):format(3),
   inventory_image = "technic_mining_drill_mk3.png",
   wear_represents = "technic_RE_charge",
   on_refill = technic.refill_RE_charge,
   on_use = function(itemstack, user, pointed_thing)
   mining_drill_mk3_handler(itemstack,user,pointed_thing)
   return itemstack
@@ -388,6 +402,8 @@
      description = S("Mining Drill Mk%d Mode %d"):format(3, i),
      inventory_image = "technic_mining_drill_mk3.png^technic_tool_mode"..i..".png",
      wield_image = "technic_mining_drill_mk3.png",
      wear_represents = "technic_RE_charge",
      on_refill = technic.refill_RE_charge,
      groups = {not_in_creative_inventory=1},
      on_use = function(itemstack, user, pointed_thing)
      mining_drill_mk3_handler(itemstack,user,pointed_thing)