[gs]et_attribute -> meta methods

This commit is contained in:
SX 2020-02-16 22:13:38 +02:00
parent f0eeb034ae
commit ba32518215

View File

@ -1,19 +1,19 @@
local increase_stat = function(player, name, value) local increase_stat = function(player, name, value)
if player == nil or player.get_attribute == nil then if player == nil or player.get_meta == nil then
-- fake player -- fake player
return return
end end
local count = player:get_attribute(name) local meta = player:get_meta()
local count = meta:get_int(name)
if not count then if not count then
count = 0 count = 0
end end
local newValue = count + value local newValue = count + value
player:set_attribute(name, newValue) meta:set_int(name, newValue)
xp_redo.run_hook("stat_change", { player:get_player_name(), name, newValue }) xp_redo.run_hook("stat_change", { player:get_player_name(), name, newValue })
end end
@ -28,7 +28,6 @@ minetest.register_globalstep(function(dtime)
end end
end) end)
minetest.register_on_dignode(function(_, _, player) minetest.register_on_dignode(function(_, _, player)
if player and player:is_player() then if player and player:is_player() then
increase_stat(player, "digged_nodes", 1) increase_stat(player, "digged_nodes", 1)