player atributes: use player:get_meta() instead.
This commit is contained in:
parent
abec3f27a7
commit
4fdbdc020b
@ -227,7 +227,8 @@ function boxes.player_success(player)
|
|||||||
end
|
end
|
||||||
-- omit check if tutorial is actually required here
|
-- omit check if tutorial is actually required here
|
||||||
if sid == conf.tutorial.series then
|
if sid == conf.tutorial.series then
|
||||||
player:set_attribute("tutorial_completed", 1)
|
local pmeta = player:get_meta()
|
||||||
|
pmeta:set_string("tutorial_completed", "1")
|
||||||
announce.all(name .. " completed the tutorial!")
|
announce.all(name .. " completed the tutorial!")
|
||||||
announce.admins(name .. " completed the tutorial!")
|
announce.admins(name .. " completed the tutorial!")
|
||||||
-- reward: create priv
|
-- reward: create priv
|
||||||
@ -461,9 +462,10 @@ function boxes.next_series(player, sid, is_entering)
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
local pmeta = player:get_meta()
|
||||||
if sid == conf.tutorial.series and
|
if sid == conf.tutorial.series and
|
||||||
conf.tutorial.required and
|
conf.tutorial.required and
|
||||||
player:get_attribute("tutorial_completed") ~= "1" then
|
pmeta:get_string("tutorial_completed") ~= "1" then
|
||||||
boxes.open_box(player, {conf.tutorial.entry_lobby, bxs[index], conf.tutorial.exit_lobby})
|
boxes.open_box(player, {conf.tutorial.entry_lobby, bxs[index], conf.tutorial.exit_lobby})
|
||||||
else
|
else
|
||||||
boxes.open_box(player, {0, bxs[index], 1})
|
boxes.open_box(player, {0, bxs[index], 1})
|
||||||
|
@ -630,7 +630,8 @@ do_creator_if = function(player, context)
|
|||||||
f = f .. "button[8.4,0;3.4,1;series;"..FE(S("Manage Series")).."]"
|
f = f .. "button[8.4,0;3.4,1;series;"..FE(S("Manage Series")).."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local limit = tonumber(player:get_attribute("box_create_limit") or "3")
|
local pmeta = player:get_meta()
|
||||||
|
local limit = tonumber(pmeta:get_string("box_create_limit") or "3")
|
||||||
|
|
||||||
if (minetest.check_player_privs(name, "create") and counts.editing + counts.submitted <= limit) or
|
if (minetest.check_player_privs(name, "create") and counts.editing + counts.submitted <= limit) or
|
||||||
minetest.check_player_privs(name, "review") then
|
minetest.check_player_privs(name, "review") then
|
||||||
|
@ -30,7 +30,8 @@ local S = minetest.get_translator("menu")
|
|||||||
local FE = minetest.formspec_escape
|
local FE = minetest.formspec_escape
|
||||||
|
|
||||||
local function toggle_music(player)
|
local function toggle_music(player)
|
||||||
local m = player:get_attribute("music")
|
local pmeta = player:get_meta()
|
||||||
|
local m = pmeta:get_string("music")
|
||||||
if not m or m == "1" then
|
if not m or m == "1" then
|
||||||
music.stop(player)
|
music.stop(player)
|
||||||
m = "0"
|
m = "0"
|
||||||
@ -39,7 +40,7 @@ local function toggle_music(player)
|
|||||||
m = "1"
|
m = "1"
|
||||||
minetest.chat_send_player(player:get_player_name(), S("Music is now enabled. Music playback will start later."))
|
minetest.chat_send_player(player:get_player_name(), S("Music is now enabled. Music playback will start later."))
|
||||||
end
|
end
|
||||||
player:set_attribute("music", m)
|
pmeta:set_string("music", m)
|
||||||
end
|
end
|
||||||
|
|
||||||
sfinv.register_page("menu:lobby", {
|
sfinv.register_page("menu:lobby", {
|
||||||
@ -317,7 +318,8 @@ sfinv.register_page("menu:play", {
|
|||||||
box.box_id, bmeta.meta.box_name, bmeta.meta.builder)) .. "]"
|
box.box_id, bmeta.meta.box_name, bmeta.meta.builder)) .. "]"
|
||||||
local leave_btn = "button[0.5,2.1;4,0.6;leave;"..FE(S("Leave this box")).."]"
|
local leave_btn = "button[0.5,2.1;4,0.6;leave;"..FE(S("Leave this box")).."]"
|
||||||
if conf.tutorial.required then
|
if conf.tutorial.required then
|
||||||
if player:get_attribute("tutorial_completed") ~= "1" then
|
local pmeta = player:get_meta()
|
||||||
|
if pmeta:get_string("tutorial_completed") ~= "1" then
|
||||||
leave_btn = ""
|
leave_btn = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,8 @@ music.start = function(player, info, tag)
|
|||||||
-- ignore if music disabled.
|
-- ignore if music disabled.
|
||||||
music.stop(player)
|
music.stop(player)
|
||||||
|
|
||||||
if player:get_attribute("music") == "0" then
|
local pmeta = player:get_meta()
|
||||||
|
if pmeta:get_string("music") == "0" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,7 +73,8 @@ function perks.grant(name_or_player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if accepted >= 3 then
|
if accepted >= 3 then
|
||||||
local limit = tonumber(player:get_attribute("box_create_limit") or "3")
|
local pmeta = player:get_meta()
|
||||||
|
local limit = tonumber(pmeta:get_string("box_create_limit") or "3")
|
||||||
if limit <= 3 then
|
if limit <= 3 then
|
||||||
minetest.log("perks: granted more boxes to " .. name)
|
minetest.log("perks: granted more boxes to " .. name)
|
||||||
announce.all(name .. " has been granted the more boxes perk!")
|
announce.all(name .. " has been granted the more boxes perk!")
|
||||||
@ -91,7 +92,7 @@ function perks.grant(name_or_player)
|
|||||||
"--sofar"
|
"--sofar"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
player:set_attribute("box_create_limit", "5")
|
pmeta:set_string("box_create_limit", "5")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -301,7 +301,8 @@ end)
|
|||||||
-- event handlers
|
-- event handlers
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
-- set appearance
|
-- set appearance
|
||||||
local skin = player:get_attribute("skin")
|
local pmeta = player:get_meta()
|
||||||
|
local skin = pmeta:get_string("skin")
|
||||||
if not skin then
|
if not skin then
|
||||||
local default_skins = {
|
local default_skins = {
|
||||||
"skin_jack.png",
|
"skin_jack.png",
|
||||||
@ -373,7 +374,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- return all players to the lobby, or throw them into the tutorial
|
-- return all players to the lobby, or throw them into the tutorial
|
||||||
if conf.tutorial.required and player:get_attribute("tutorial_completed") ~= "1" then
|
if conf.tutorial.required and pmeta:get_string("tutorial_completed") ~= "1" then
|
||||||
if boxes.next_series(player, conf.tutorial.series) then
|
if boxes.next_series(player, conf.tutorial.series) then
|
||||||
-- should be in a box now
|
-- should be in a box now
|
||||||
return
|
return
|
||||||
@ -413,7 +414,8 @@ sfinv.register_page("player:skin", {
|
|||||||
if minetest.check_player_privs(player, "review") then
|
if minetest.check_player_privs(player, "review") then
|
||||||
skin = skin .. "^skin_overlay_admin.png"
|
skin = skin .. "^skin_overlay_admin.png"
|
||||||
end
|
end
|
||||||
player:set_attribute("skin", skin)
|
local pmeta = player:get_meta()
|
||||||
|
pmeta:set_string("skin", skin)
|
||||||
player:set_properties({textures = {skin}})
|
player:set_properties({textures = {skin}})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -488,14 +490,16 @@ minetest.register_chatcommand("attr", {
|
|||||||
if not p then
|
if not p then
|
||||||
return false, S("No such player.")
|
return false, S("No such player.")
|
||||||
end
|
end
|
||||||
p:set_attribute(params[3], params[4])
|
local pmeta = p:get_meta()
|
||||||
|
pmeta:set_string(params[3], params[4])
|
||||||
return true, S("Attribute set.")
|
return true, S("Attribute set.")
|
||||||
elseif params[1] == "get" then
|
elseif params[1] == "get" then
|
||||||
local p = minetest.get_player_by_name(params[2])
|
local p = minetest.get_player_by_name(params[2])
|
||||||
if not p then
|
if not p then
|
||||||
return false, S("No such player.")
|
return false, S("No such player.")
|
||||||
end
|
end
|
||||||
return true, params[3] .. "=" .. dump(p:get_attribute(params[3]))
|
local pmeta = player:get_meta()
|
||||||
|
return true, params[3] .. "=" .. dump(pmeta:get_string(params[3]))
|
||||||
else
|
else
|
||||||
return false, S("Usage: /attr <get|set> <name> <attribute> <value>")
|
return false, S("Usage: /attr <get|set> <name> <attribute> <value>")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user