experience: store data in own folder
This commit is contained in:
parent
cf3314bb79
commit
c0efa4e510
@ -47,20 +47,20 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
end)
|
||||
--give a new player some xp
|
||||
minetest.register_on_newplayer(function(player)
|
||||
file = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "w")
|
||||
file = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "w")
|
||||
file:write("0")
|
||||
file:close()
|
||||
end)
|
||||
--set player's xp level to 0 if they die
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
file = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "w")
|
||||
file = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "w")
|
||||
file:write("0")
|
||||
file:close()
|
||||
end)
|
||||
local xp_hud = nil
|
||||
--hudbar by D00Med
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
xp = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "r")
|
||||
xp = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "r")
|
||||
experience = xp:read("*l")
|
||||
xp:close()
|
||||
local playername = player:get_player_name()
|
||||
@ -88,7 +88,7 @@ end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
xp = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "r")
|
||||
xp = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "r")
|
||||
experience = xp:read("*l")
|
||||
expe = experience/20
|
||||
xp:close()
|
||||
@ -109,14 +109,14 @@ minetest.register_globalstep(function(dtime)
|
||||
minetest.sound_play("orb", {
|
||||
to_player = player:get_player_name(),
|
||||
})
|
||||
xp = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "r")
|
||||
xp = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "r")
|
||||
experience = tonumber(xp:read("*l"))
|
||||
xp:close()
|
||||
if experience ~= nil then
|
||||
local xp_max = experience+1
|
||||
if xp_max <= 1000 then
|
||||
new_xp = experience + 1
|
||||
xp_write = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "w")
|
||||
xp_write = io.open(minetest.get_worldpath().."/experience/"..player:get_player_name(), "w")
|
||||
xp_write:write(new_xp)
|
||||
xp_write:close()
|
||||
if new_xp == level1 then
|
||||
|
Loading…
x
Reference in New Issue
Block a user