Checks if a node is protected.
Note: this page has been written for Advtrains 2.0.1 TSS and Minetest 5.1.0. Examples and practices described in this page don't take advantage of improvements introduced in later releases.
advtrains.is_protected(pos, name)
pos
(table): a Minetest position vector.name
(string): the player name. It does not need to be logged in, but it *needs* to exist in the auth.txt
file.True if the node is protected and the player cannot bypass this protection, false otherwise.
It gives an error if the name
parameter is nil:
2019-01-01 15:00:00: Error[Server]: advtrains.is_protected() called without name parameter!
This Lua function checks whether the designated player has the protection_bypass
privilege. If not, it checks whether the node is protected by using the minetest.is_protected
function, which may be overridden by protection mods.
If the player has the protection_bypass
privilege, Advtrains considers all nodes “unprotected” regardless of current protection status.
Consider that you are running a Minetest server and:
alice
and bob
are connected to the serveralice
has the protection_bypass
privilege while bob
has no privilegesadvtrains.is_protected({x=0, y=1,y=5}, "alice") -- returns false: node is protected, but protection bypass is enabled for this user advtrains.is_protected({x=0, y=1,y=5}, "bob") -- returns true: node is protected advtrains.is_protected({x=-10,y=0,y=0}, "bob") -- returns false: node is not protected
advtrains/helpers.lua, lines 214 to 223:
function advtrains.is_protected(pos, name) if not name then error("advtrains.is_protected() called without name parameter!") end if minetest.check_player_privs(name, {protection_bypass=true}) then --player can bypass protection return false end return minetest.is_protected(pos, name) end