Zefram
2014-08-17 d0efa15b983f7a0a96e1a7abcdad713715dfeeeb
technic/register.lua
@@ -3,6 +3,7 @@
technic.receiver = "RE"
technic.producer = "PR"
technic.producer_receiver = "PR_RE"
technic.battery  = "BA"
technic.machines    = {}
@@ -44,7 +45,15 @@
-- Wear down a tool depending on the remaining charge.
function technic.set_RE_wear(itemstack, item_load, max_load)
   local temp = 65536 - math.floor(item_load / max_load * 65535)
   if (minetest.registered_items[itemstack:get_name()].wear_represents or "mechanical_wear") ~= "technic_RE_charge" then return itemstack end
   local temp
   if item_load == 0 then
      temp = 0
   else
      temp = 65536 - math.floor(item_load / max_load * 65535)
      if temp > 65535 then temp = 65535 end
      if temp < 1 then temp = 1 end
   end
   itemstack:set_wear(temp)
   return itemstack
end