Add minetest.is_creative_enabled
This commit is contained in:
parent
a57ab6d2dc
commit
b4d042ef54
|
@ -345,17 +345,11 @@ if INIT == "game" then
|
||||||
--Wrapper for rotate_and_place() to check for sneak and assume Creative mode
|
--Wrapper for rotate_and_place() to check for sneak and assume Creative mode
|
||||||
--implies infinite stacks when performing a 6d rotation.
|
--implies infinite stacks when performing a 6d rotation.
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local creative_mode_cache = core.settings:get_bool("creative_mode")
|
|
||||||
local function is_creative(name)
|
|
||||||
return creative_mode_cache or
|
|
||||||
core.check_player_privs(name, {creative = true})
|
|
||||||
end
|
|
||||||
|
|
||||||
core.rotate_node = function(itemstack, placer, pointed_thing)
|
core.rotate_node = function(itemstack, placer, pointed_thing)
|
||||||
local name = placer and placer:get_player_name() or ""
|
local name = placer and placer:get_player_name() or ""
|
||||||
local invert_wall = placer and placer:get_player_control().sneak or false
|
local invert_wall = placer and placer:get_player_control().sneak or false
|
||||||
return core.rotate_and_place(itemstack, placer, pointed_thing,
|
return core.rotate_and_place(itemstack, placer, pointed_thing,
|
||||||
is_creative(name),
|
core.is_creative_enabled(name),
|
||||||
{invert_wall = invert_wall}, true)
|
{invert_wall = invert_wall}, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -582,7 +582,7 @@ function core.node_dig(pos, node, digger)
|
||||||
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
|
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
|
||||||
else
|
else
|
||||||
-- Wear out tool
|
-- Wear out tool
|
||||||
if not core.settings:get_bool("creative_mode") then
|
if not core.is_creative_enabled(diggername) then
|
||||||
wielded:add_wear(dp.wear)
|
wielded:add_wear(dp.wear)
|
||||||
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||||
core.sound_play(wdef.sound.breaks, {
|
core.sound_play(wdef.sound.breaks, {
|
||||||
|
|
|
@ -164,6 +164,12 @@ function core.record_protection_violation(pos, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- To be overridden by Creative mods
|
||||||
|
|
||||||
|
local creative_mode_cache = core.settings:get_bool("creative_mode")
|
||||||
|
function core.is_creative_enabled(name)
|
||||||
|
return creative_mode_cache
|
||||||
|
end
|
||||||
|
|
||||||
-- Checks if specified volume intersects a protected volume
|
-- Checks if specified volume intersects a protected volume
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue