ShadowNinja
2013-10-19 eac48441754260fe42c7a605e72141a79ed79bc1
technic/tools/mining_laser_mk1.lua
@@ -1,7 +1,7 @@
local laser_mk1_max_charge = 40000
technic.register_power_tool("technic:laser_mk1", laser_mk1_max_charge)
local laser_shoot = function(itemstack, player, pointed_thing)
local laser_shoot = function(player, pointed_thing)
            local laser_straight_mode=0
            local playerpos=player:getpos()
            local dir=player:get_look_dir()
@@ -55,18 +55,15 @@
   inventory_image = "technic_mining_laser_mk1.png",
   stack_max = 1,
   on_use = function(itemstack, user, pointed_thing)
      item=itemstack:to_table()
      local meta=get_item_meta(item["metadata"])
      if meta==nil then return end --tool not charghed
      if meta["charge"]==nil then return end
      charge=meta["charge"]
      if charge-400>0 then
       laser_shoot(item, user, pointed_thing)
       charge = charge-400;
      technic.set_RE_wear(item,charge,laser_mk1_max_charge)
      meta["charge"]=charge
      item["metadata"]=set_item_meta(meta)
      itemstack:replace(item)
      local meta = get_item_meta(itemstack:get_metadata())
      if not meta or not meta.charge then
         return
      end
      if meta.charge - 400 > 0 then
         laser_shoot(user, pointed_thing)
         meta.charge = meta.charge - 400
         technic.set_RE_wear(itemstack, meta.charge, laser_mk1_max_charge)
         itemstack:set_metadata(set_item_meta(meta))
      end
      return itemstack
   end,