Screwdriver fix
authorMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 23:29:42 +0000 (01:29 +0200)
committerMaciej Kasatkin <mk@realbadangel.pl>
Tue, 11 Sep 2012 23:29:42 +0000 (01:29 +0200)
screwdriver.lua

index c8aaa7b1242a6e678f2d61d52b8f226e81f8e9d0..aebef80691e41c575f670f74d70dd4b432ee8699 100644 (file)
                    minetest.env:set_node(pos,node)
                     meta = minetest.env:get_meta(pos)
                     meta:from_table(meta0)
-                    -- appropriatly set the wear of the screwdriver
-                   -- m = itemstack:get_wear()
-                   -- if m == 0 then m = 65535 end
-                   -- m = m-6554
-                   -- return {wear=m}
-            end,
+                   local item=itemstack:to_table()
+                   local item_wear=tonumber((item["wear"])) 
+                   item_wear=item_wear+819
+                   if item_wear>65535 then itemstack:clear() return itemstack end
+                   item["wear"]=tostring(item_wear)
+                   itemstack:replace(item)
+                   return itemstack
+           end,
     })
      
     minetest.register_craft({