summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorWuzzy <Wuzzy2@mail.ru>2020-05-26 02:11:19 +0200
committersfan5 <sfan5@live.de>2020-05-29 22:45:40 +0200
commit65a6a316d081d3951438bbbcfce74c9c65db407a (patch)
treeb063fae3fd4bb9d75be05905f6f53ae19982fb01 /builtin
parent9a64a9fd9427fc3b62d4dc9bf1ca7c15477ebc5a (diff)
downloadminetest-65a6a316d081d3951438bbbcfce74c9c65db407a.tar.gz
minetest-65a6a316d081d3951438bbbcfce74c9c65db407a.tar.bz2
minetest-65a6a316d081d3951438bbbcfce74c9c65db407a.zip
Add minetest.is_creative_enabled
Diffstat (limited to 'builtin')
-rw-r--r--builtin/common/misc_helpers.lua10
-rw-r--r--builtin/game/item.lua2
-rw-r--r--builtin/game/misc.lua6
3 files changed, 9 insertions, 9 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 1a0c71efd..a88adf96d 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -345,18 +345,12 @@ if INIT == "game" then
--Wrapper for rotate_and_place() to check for sneak and assume Creative mode
--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)
local name = placer and placer:get_player_name() or ""
local invert_wall = placer and placer:get_player_control().sneak or false
return core.rotate_and_place(itemstack, placer, pointed_thing,
- is_creative(name),
- {invert_wall = invert_wall}, true)
+ core.is_creative_enabled(name),
+ {invert_wall = invert_wall}, true)
end
end
diff --git a/builtin/game/item.lua b/builtin/game/item.lua
index 3aaa71ef2..f680ce0d4 100644
--- a/builtin/game/item.lua
+++ b/builtin/game/item.lua
@@ -582,7 +582,7 @@ function core.node_dig(pos, node, digger)
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
else
-- 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)
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
core.sound_play(wdef.sound.breaks, {
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua
index 0ed11ada0..341e613c2 100644
--- a/builtin/game/misc.lua
+++ b/builtin/game/misc.lua
@@ -164,6 +164,12 @@ function core.record_protection_violation(pos, name)
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