Checks if the user is in creative mode.
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_creative(name)
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 creative mode is enabled for the player, false otherwise.
It gives an error if the name
parameter is nil:
2019-01-01 15:00:00: Error[Server]: advtrains.is_creative() called without name parameter!
This Lua function checks whether the designated player has the creative
privilege. If not, it checks whether the global Creative Mode option has been enabled in the main menu. If either condition is true, Advtrains considers that creative mode is enabled.
Consider that you are running a Minetest server and:
alice
and bob
are connected to the serveralice
has the creative
privilege while bob
has no privilegesadvtrains.is_creative("alice") -- returns true in all cases advtrains.is_creative("bob") -- returns true only when Creative Mode is enabled advtrains.is_creative("unknown") -- returns true only when Creative Mode is enabled
advtrains/helpers.lua, lines 255 to 233:
function advtrains.is_creative(name) if not name then error("advtrains.is_creative() called without name parameter!") end if minetest.check_player_privs(name, {creative=true}) then return true end return minetest.settings:get_bool("creative_mode") end