aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/misc.lua
diff options
context:
space:
mode:
authorrubenwardy <rubenwardy@gmail.com>2017-01-18 10:19:57 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-01-18 11:19:57 +0100
commitc5967f75f0a9827d1b65b384edd6ba07c73ffd2f (patch)
treec52b2a94a74c9513a103e86ba670a6d38a7be278 /builtin/game/misc.lua
parenta378e32751127e2ae3708a33f035d1dcf5d400a1 (diff)
downloadminetest-c5967f75f0a9827d1b65b384edd6ba07c73ffd2f.tar.gz
minetest-c5967f75f0a9827d1b65b384edd6ba07c73ffd2f.tar.bz2
minetest-c5967f75f0a9827d1b65b384edd6ba07c73ffd2f.zip
Add minetest.player_exists() (#5064)
Diffstat (limited to 'builtin/game/misc.lua')
-rw-r--r--builtin/game/misc.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua
index 7caa9e7ba..3419c1980 100644
--- a/builtin/game/misc.lua
+++ b/builtin/game/misc.lua
@@ -56,11 +56,11 @@ function core.check_player_privs(name, ...)
elseif arg_type ~= "string" then
error("Invalid core.check_player_privs argument type: " .. arg_type, 2)
end
-
+
local requested_privs = {...}
local player_privs = core.get_player_privs(name)
local missing_privileges = {}
-
+
if type(requested_privs[1]) == "table" then
-- We were provided with a table like { privA = true, privB = true }.
for priv, value in pairs(requested_privs[1]) do
@@ -76,11 +76,11 @@ function core.check_player_privs(name, ...)
end
end
end
-
+
if #missing_privileges > 0 then
return false, missing_privileges
end
-
+
return true, ""
end
@@ -114,6 +114,10 @@ function core.get_connected_players()
return temp_table
end
+function minetest.player_exists(name)
+ return minetest.get_auth_handler().get_auth(name) ~= nil
+end
+
-- Returns two position vectors representing a box of `radius` in each
-- direction centered around the player corresponding to `player_name`
function core.get_player_radius_area(player_name, radius)
@@ -244,4 +248,3 @@ end
function core.close_formspec(player_name, formname)
return minetest.show_formspec(player_name, formname, "")
end
-