User Tools

Site Tools


Minetest Forum
Content Database
Git Repository
Bug Tracker



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.

Errors and warnings

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!

How it works internally

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:

  • Two players, alice and bob are connected to the server
  • alice has the protection_bypass privilege while bob has no privileges
  • Node at position (0,1,5) has been protected
advtrains.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

In source code

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!")
    if minetest.check_player_privs(name, {protection_bypass=true}) then
        --player can bypass protection
        return false
    return minetest.is_protected(pos, name)
dev/core/funref/is_protected.txt · Last modified: 2020-01-22 10:53 by admin