Table of Contents

advtrains.is_creative

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.

Syntax

advtrains.is_creative(name)

Parameters

Returns

True if the creative mode is enabled for the player, 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_creative() called without name parameter!

How it works internally

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.

Examples

Consider that you are running a Minetest server and:

advtrains.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

In source code

advtrains/helpers.lua, lines 255 to 233:

is_creative.lua
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