diff --git a/technic/register.lua b/technic/register.lua index 288db57..0b55282 100644 --- a/technic/register.lua +++ b/technic/register.lua @@ -44,7 +44,14 @@ end -- 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) + 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 diff --git a/technic/tools/mining_lasers.lua b/technic/tools/mining_lasers.lua index b80e878..4a4ed2f 100644 --- a/technic/tools/mining_lasers.lua +++ b/technic/tools/mining_lasers.lua @@ -178,7 +178,6 @@ for _, m in pairs(mining_lasers_list) do if meta.charge >= m[4] then meta.charge = meta.charge - m[4] laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1]) - meta.charge = meta.charge - 400 technic.set_RE_wear(itemstack, meta.charge, m[3]) itemstack:set_metadata(minetest.serialize(meta)) end