only update meta when needed

only update dug and level meta when needed
This commit is contained in:
tenplus1 2017-07-28 13:50:04 +01:00 committed by GitHub
parent 813897b514
commit 3def30b634
1 changed files with 2 additions and 2 deletions

View File

@ -58,6 +58,7 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
-- Only count nodes that spend the tool -- Only count nodes that spend the tool
if(digparams.wear > 0) then if(digparams.wear > 0) then
dugnodes = dugnodes + 1 dugnodes = dugnodes + 1
itemmeta:set_string("dug", dugnodes)
end end
if(itemstack:get_wear() > 60135) then if(itemstack:get_wear() > 60135) then
minetest.chat_send_player(user:get_player_name(), "Your tool is about to break, comrade!") minetest.chat_send_player(user:get_player_name(), "Your tool is about to break, comrade!")
@ -77,12 +78,11 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
gain = 2.0, gain = 2.0,
}) })
minetest.chat_send_player(user:get_player_name(), levelup_text) minetest.chat_send_player(user:get_player_name(), levelup_text)
itemmeta:set_string("lastlevel", level)
end end
local newdesc = toolranks.create_description(itemdesc, dugnodes, level) local newdesc = toolranks.create_description(itemdesc, dugnodes, level)
itemmeta:set_string("lastlevel", level)
itemmeta:set_string("dug", dugnodes)
itemmeta:set_string("description", newdesc) itemmeta:set_string("description", newdesc)
local wear = digparams.wear local wear = digparams.wear
if level > 1 then if level > 1 then