parent
f4854282b7
commit
48ec0f186d
|
@ -97,7 +97,7 @@ xp_redo.add_xp = function(playername, xp)
|
||||||
-- level up
|
-- level up
|
||||||
xp_redo.run_hook("rank_change", { playername, sumXp, currentRank })
|
xp_redo.run_hook("rank_change", { playername, sumXp, currentRank })
|
||||||
|
|
||||||
local state = player:get_attribute(xp_redo.HUD_DISPLAY_STATE_NAME)
|
local state = player:get_meta():get(xp_redo.HUD_DISPLAY_STATE_NAME)
|
||||||
if state and state == "on" then
|
if state and state == "on" then
|
||||||
level_up(player, currentRank)
|
level_up(player, currentRank)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,18 +28,18 @@ local update_highscore = function()
|
||||||
|
|
||||||
for _,player in pairs(players) do
|
for _,player in pairs(players) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local xp = player:get_meta():get_int("xp")
|
||||||
local found = false
|
local found = false
|
||||||
for _,entry in pairs(xp_redo.highscore) do
|
for _,entry in pairs(xp_redo.highscore) do
|
||||||
if entry.name == name then
|
if entry.name == name then
|
||||||
-- connected player already exists in highscore, update value
|
-- connected player already exists in highscore, update value
|
||||||
entry.xp = tonumber(player:get_attribute("xp")) or 0
|
entry.xp = xp
|
||||||
found = true
|
found = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
-- create new entry
|
-- create new entry
|
||||||
local xp = tonumber(player:get_attribute("xp") or "0")
|
|
||||||
table.insert(xp_redo.highscore, { name=name, xp=xp })
|
table.insert(xp_redo.highscore, { name=name, xp=xp })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
6
hud.lua
6
hud.lua
|
@ -21,7 +21,7 @@ local setup_hud = function(player)
|
||||||
|
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
player:set_attribute(xp_redo.HUD_DISPLAY_STATE_NAME, "on")
|
player:get_meta():set_string(xp_redo.HUD_DISPLAY_STATE_NAME, "on")
|
||||||
|
|
||||||
data.info = player:hud_add({
|
data.info = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
|
@ -91,7 +91,7 @@ local remove_hud = function(player)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local data = hud[playername]
|
local data = hud[playername]
|
||||||
|
|
||||||
player:set_attribute(xp_redo.HUD_DISPLAY_STATE_NAME, "off")
|
player:get_meta():set_string(xp_redo.HUD_DISPLAY_STATE_NAME, "off")
|
||||||
|
|
||||||
|
|
||||||
if not data then
|
if not data then
|
||||||
|
@ -203,7 +203,7 @@ xp_redo.update_hud = function(player, xp, rank, next_rank)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local state = player:get_attribute(xp_redo.HUD_DISPLAY_STATE_NAME)
|
local state = player:get_meta():get(xp_redo.HUD_DISPLAY_STATE_NAME)
|
||||||
if not state or state == "on" then
|
if not state or state == "on" then
|
||||||
setup_hud(player)
|
setup_hud(player)
|
||||||
end
|
end
|
||||||
|
|
20
mobs.lua
20
mobs.lua
|
@ -1,30 +1,26 @@
|
||||||
|
|
||||||
local increment_punch_count = function(player)
|
local increment_punch_count = function(player)
|
||||||
if player == nil or player.get_attribute == nil then
|
if player == nil or player.is_fake_player then
|
||||||
-- fake player
|
-- fake player
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local count = player:get_attribute("punch_count")
|
local meta = player:get_meta()
|
||||||
if not count then
|
local count = meta:get_int("punch_count")
|
||||||
count = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
player:set_attribute("punch_count", count + 1)
|
meta:set_int("punch_count", count + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local increase_inflicted_damage = function(player, value)
|
local increase_inflicted_damage = function(player, value)
|
||||||
if player == nil or player.get_attribute == nil then
|
if player == nil or player.is_fake_player then
|
||||||
-- fake player
|
-- fake player
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local count = player:get_attribute("inflicted_damage")
|
local meta = player:get_meta()
|
||||||
if not count then
|
local count = meta:get_int("inflicted_damage")
|
||||||
count = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
player:set_attribute("inflicted_damage", count + value)
|
meta:set_int("inflicted_damage", count + value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue