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)
|
end)
|
||||||
--give a new player some xp
|
--give a new player some xp
|
||||||
minetest.register_on_newplayer(function(player)
|
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:write("0")
|
||||||
file:close()
|
file:close()
|
||||||
end)
|
end)
|
||||||
--set player's xp level to 0 if they die
|
--set player's xp level to 0 if they die
|
||||||
minetest.register_on_dieplayer(function(player)
|
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:write("0")
|
||||||
file:close()
|
file:close()
|
||||||
end)
|
end)
|
||||||
local xp_hud = nil
|
local xp_hud = nil
|
||||||
--hudbar by D00Med
|
--hudbar by D00Med
|
||||||
minetest.register_on_joinplayer(function(player)
|
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")
|
experience = xp:read("*l")
|
||||||
xp:close()
|
xp:close()
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
@ -88,7 +88,7 @@ end)
|
|||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
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")
|
experience = xp:read("*l")
|
||||||
expe = experience/20
|
expe = experience/20
|
||||||
xp:close()
|
xp:close()
|
||||||
@ -109,14 +109,14 @@ minetest.register_globalstep(function(dtime)
|
|||||||
minetest.sound_play("orb", {
|
minetest.sound_play("orb", {
|
||||||
to_player = player:get_player_name(),
|
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"))
|
experience = tonumber(xp:read("*l"))
|
||||||
xp:close()
|
xp:close()
|
||||||
if experience ~= nil then
|
if experience ~= nil then
|
||||||
local xp_max = experience+1
|
local xp_max = experience+1
|
||||||
if xp_max <= 1000 then
|
if xp_max <= 1000 then
|
||||||
new_xp = experience + 1
|
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:write(new_xp)
|
||||||
xp_write:close()
|
xp_write:close()
|
||||||
if new_xp == level1 then
|
if new_xp == level1 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user