Add minetest.player_exists() (#5064)
This commit is contained in:
parent
a378e32751
commit
c5967f75f0
@ -56,11 +56,11 @@ function core.check_player_privs(name, ...)
|
|||||||
elseif arg_type ~= "string" then
|
elseif arg_type ~= "string" then
|
||||||
error("Invalid core.check_player_privs argument type: " .. arg_type, 2)
|
error("Invalid core.check_player_privs argument type: " .. arg_type, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local requested_privs = {...}
|
local requested_privs = {...}
|
||||||
local player_privs = core.get_player_privs(name)
|
local player_privs = core.get_player_privs(name)
|
||||||
local missing_privileges = {}
|
local missing_privileges = {}
|
||||||
|
|
||||||
if type(requested_privs[1]) == "table" then
|
if type(requested_privs[1]) == "table" then
|
||||||
-- We were provided with a table like { privA = true, privB = true }.
|
-- We were provided with a table like { privA = true, privB = true }.
|
||||||
for priv, value in pairs(requested_privs[1]) do
|
for priv, value in pairs(requested_privs[1]) do
|
||||||
@ -76,11 +76,11 @@ function core.check_player_privs(name, ...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #missing_privileges > 0 then
|
if #missing_privileges > 0 then
|
||||||
return false, missing_privileges
|
return false, missing_privileges
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, ""
|
return true, ""
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,6 +114,10 @@ function core.get_connected_players()
|
|||||||
return temp_table
|
return temp_table
|
||||||
end
|
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
|
-- Returns two position vectors representing a box of `radius` in each
|
||||||
-- direction centered around the player corresponding to `player_name`
|
-- direction centered around the player corresponding to `player_name`
|
||||||
function core.get_player_radius_area(player_name, radius)
|
function core.get_player_radius_area(player_name, radius)
|
||||||
@ -244,4 +248,3 @@ end
|
|||||||
function core.close_formspec(player_name, formname)
|
function core.close_formspec(player_name, formname)
|
||||||
return minetest.show_formspec(player_name, formname, "")
|
return minetest.show_formspec(player_name, formname, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2583,6 +2583,7 @@ These functions return the leftover itemstack.
|
|||||||
|
|
||||||
### Misc.
|
### Misc.
|
||||||
* `minetest.get_connected_players()`: returns list of `ObjectRefs`
|
* `minetest.get_connected_players()`: returns list of `ObjectRefs`
|
||||||
|
* `minetest.player_exists(name)`: boolean, whether player exists (regardless of online status)
|
||||||
* `minetest.hud_replace_builtin(name, hud_definition)`
|
* `minetest.hud_replace_builtin(name, hud_definition)`
|
||||||
* Replaces definition of a builtin hud element
|
* Replaces definition of a builtin hud element
|
||||||
* `name`: `"breath"` or `"health"`
|
* `name`: `"breath"` or `"health"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user