fix creative mode mod backguard compatibility for all engines
* dont follow the creative upstream mod, its just wrapper around get_bool(creative) setting, so create a check privilegie function and provide backguard compatibility checks * backported fix fromc770d5cb43
same backported fromc770d5cb43
This commit is contained in:
parent
137ae5c18f
commit
df6f2eb80a
22
init.lua
22
init.lua
@ -68,28 +68,24 @@ minetest.register_privilege("creative", privs_definition)
|
|||||||
|
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
|
|
||||||
-- backguard compatibility
|
function minetest.is_creative_enabled(name)
|
||||||
function creative.is_creative(name)
|
if name == "" then
|
||||||
if creative.is_53 then
|
return creative_mode_cache
|
||||||
if name == "" then
|
|
||||||
return minetest.is_creative_enabled(name)
|
|
||||||
else
|
|
||||||
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Override the engine's creative mode function
|
-- backguard compatibility
|
||||||
local old_is_creative_enabled = creative.is_creative
|
function creative.is_creative(name)
|
||||||
function minetest.is_creative_enabled(name)
|
|
||||||
if name == "" then
|
if name == "" then
|
||||||
return old_is_creative_enabled(name)
|
return creative_mode_cache
|
||||||
|
else
|
||||||
|
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||||
end
|
end
|
||||||
return minetest.check_player_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- For backwards compatibility:
|
-- For backwards compatibility:
|
||||||
function creative.is_enabled_for(name)
|
function creative.is_enabled_for(name)
|
||||||
return creative.is_creative(name)
|
return creative.is_creative(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user