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
a3a7b39333
commit
4d394d8a5f
@ -1,3 +1,5 @@
|
||||
-- creative/init.lua
|
||||
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha")
|
||||
local is_53 = minetest.has_feature("object_step_has_moveresult")
|
||||
local is_54 = minetest.has_feature("direct_velocity_on_players")
|
||||
@ -43,28 +45,24 @@ minetest.register_privilege("creative", privs_definition)
|
||||
|
||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
-- backguard compatibility
|
||||
function creative.is_creative(name)
|
||||
if creative.is_53 then
|
||||
if name == "" then
|
||||
return minetest.is_creative_enabled(name)
|
||||
else
|
||||
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||
end
|
||||
function minetest.is_creative_enabled(name)
|
||||
if name == "" then
|
||||
return creative_mode_cache
|
||||
else
|
||||
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
|
||||
end
|
||||
end
|
||||
|
||||
-- Override the engine's creative mode function
|
||||
local old_is_creative_enabled = creative.is_creative
|
||||
function minetest.is_creative_enabled(name)
|
||||
-- backguard compatibility
|
||||
function creative.is_creative(name)
|
||||
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
|
||||
return minetest.check_player_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
||||
end
|
||||
|
||||
|
||||
-- For backwards compatibility:
|
||||
function creative.is_enabled_for(name)
|
||||
return creative.is_creative(name)
|
||||
@ -326,7 +324,7 @@ else
|
||||
minetest.after(0.1, tab_items)
|
||||
end
|
||||
|
||||
creative.register_tab("all", "All", minetest.registered_items)
|
||||
creative.register_tab("all", "Creative", minetest.registered_items)
|
||||
creative.register_tab("nodes", "Nodes", minetest.registered_nodes)
|
||||
creative.register_tab("tools", "Tools", minetest.registered_tools)
|
||||
creative.register_tab("craftitems", "Items", minetest.registered_craftitems)
|
||||
|
Loading…
x
Reference in New Issue
Block a user