Say hello to XP (Plus other fixes)

This commit is contained in:
LoneWolfHT 2020-04-28 21:32:44 -07:00
parent b30a6c2a7d
commit da20a51698
5 changed files with 35 additions and 11 deletions

View File

@ -1,5 +1,3 @@
unused_args = false
globals = {
"vkore", "player_stats", "hb", "players", "gold",
"party", "nodes", "mapgen", "spawners", "pathfinder",
@ -22,7 +20,7 @@ exclude_files = {
"mods/enemies/pathfinder/astar_core.lua",
"mods/hudbars/",
"mods/mobkit/",
"mods/sfinv",
"mods/sfinv/",
"mods/screwdriver2/",
"mods/creative/",
"mods/sscsm/",

View File

@ -0,0 +1,26 @@
hb.register_hudbar("xp", 0xffffff, "XP", {bar = "xp.png"}, 0, 10, false, nil, nil)
minetest.register_on_joinplayer(function(player)
local meta = player:get_meta()
if meta:get_int("level") <= 0 then
meta:set_int("level", 1)
end
hb.init_hudbar(player, "xp", meta:get_int("xp"), meta:get_int("level") * 50)
end)
function players.add_xp(player, xp)
local meta = player:get_meta()
local new_xp = meta:get_int("xp") + xp
if new_xp >= meta:get_int("level") * 50 then
new_xp = 0
meta:set_int("level", meta:get_int("level")+1)
meta:set_int("available_statpoints", meta:get_int("available_statpoints") + player_stats.statpoints_per_level)
end
meta:set_int("xp", new_xp)
hb.change_hudbar(player, "xp", new_xp, meta:get_int("level") * 50)
end

View File

@ -24,7 +24,7 @@ minetest.register_on_leaveplayer(function(player)
gold.huds[player:get_player_name()] = nil
end)
function players.set_gold(player, gold)
function players.set_gold(player, newgold)
local name
local meta = player:get_meta()
@ -44,15 +44,15 @@ function players.set_gold(player, gold)
position = {x=0, y=1},
name = "gold_text",
scale = {x=100, y=100},
text = ": "..gold,
text = ": "..newgold,
number = 0xffd200,
alignment = {x=1, y=0},
offset = {x=48, y=-24},
z_index = 0,
})
players.hud_info_add(player, "+"..gold - meta:get_int("gold").." gold")
meta:set_int("gold", gold)
players.hud_info_add(player, "+"..newgold - meta:get_int("gold").." gold")
meta:set_int("gold", newgold)
end
function players.get_gold(player)

View File

@ -3,12 +3,12 @@ local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 30 then
timer = timer - 30
if timer >= 10 then
timer = timer - 10
for _, player in minetest.get_connected_players() do
for _, player in pairs(minetest.get_connected_players()) do
local meta = player:get_meta()
local new_hp = player:get_hp() + player:get_int("regen")
local new_hp = player:get_hp() + (meta:get_int("regen")/3)
if new_hp > meta:get_int("max_hp") then
new_hp = meta:get_int("max_hp")

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B