Carter Kolwey
2014-01-11 ebc114df71cc20868afbd3c6dea4039dc14c1a0e
technic/tools/sonic_screwdriver.lua
@@ -12,17 +12,21 @@
      if pointed_thing.type ~= "node" then
         return
      end
      local pos = minetest.get_pointed_thing_position(pointed_thing, above)
      local pos = pointed_thing.under
      if minetest.is_protected(pos, user:get_player_name()) then
         minetest.record_protection_violation(pos, user:get_player_name())
         return
      end
      local node = minetest.get_node(pos)
      local node_name = node.name
      if minetest.registered_nodes[node_name].paramtype2 ~= "facedir" and
         minetest.registered_nodes[node_name].paramtype2 ~= "wallmounted" then
         return itemstack
         return
      end
      if node.param2 == nil then
         return
      end
      local meta1 = get_item_meta(itemstack:get_metadata())
      local meta1 = minetest.deserialize(itemstack:get_metadata())
      if not meta1 or not meta1.charge then
         return
      end
@@ -44,15 +48,11 @@
         if minetest.is_protected(pos, user:get_player_name()) then
            minetest.record_protection_violation(pos, user:get_player_name())
         else
            local meta = minetest.get_meta(pos)
            local meta0 = meta:to_table()
            node.param2 = p
            minetest.set_node(pos, node)
            meta = minetest.get_meta(pos)
            meta:from_table(meta0)
            minetest.swap_node(pos, node)
            meta1.charge = meta1.charge - 100
            itemstack:set_metadata(set_item_meta(meta1))
            itemstack:set_metadata(minetest.serialize(meta1))
            technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
         end
      end
@@ -66,5 +66,6 @@
      {"default:diamond"},
      {"technic:battery"},
      {"technic:stainless_steel_ingot"}
      }
   }
})