Second function wrapper
This commit is contained in:
parent
1d71e602b8
commit
7083a26e72
|
@ -14,18 +14,22 @@ end)
|
||||||
--privs={worldedit=worldedit.priv() [, server=true]}
|
--privs={worldedit=worldedit.priv() [, server=true]}
|
||||||
--instead, I had to wrap the rest of func = .
|
--instead, I had to wrap the rest of func = .
|
||||||
worldedit.privs = function(func)
|
worldedit.privs = function(func)
|
||||||
if not minetest.setting_getbool("creative_mode") or not PROTECTION_MOD_EXISTS then
|
--this silly syntax was copied from safe_region, which is actually executed on chatcommand registration, and must return a function instead of the result of a function.
|
||||||
--no protection mod, or not the kind of world where people can just create nodes out of thin air,
|
--The innermost anonymous function is declared. Then safe_region executes, adding a function wrapper around that function. Then worldedit.privs gets that as an argument, and adds another wrapper. The doubly-wrapped function is the one registered as a chatcommand.
|
||||||
--worldedit privilege means editing anywhere
|
return function(name, param)
|
||||||
if minetest.check_player_privs(name, {worldedit=true}) then
|
if not minetest.setting_getbool("creative_mode") or not PROTECTION_MOD_EXISTS then
|
||||||
func(name, param)
|
--no protection mod, or not the kind of world where people can just create nodes out of thin air,
|
||||||
|
--worldedit privilege means editing anywhere
|
||||||
|
if minetest.check_player_privs(name, {worldedit=true}) then
|
||||||
|
func(name, param)
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return
|
--protection mod, can edit inside your area without worldedit privilege
|
||||||
|
--(worldedit and areas let you edit in no-man's land and other-owned area)
|
||||||
|
func(name, param)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
--protection mod, can edit inside your area without worldedit privilege
|
|
||||||
--(worldedit and areas let you edit in no-man's land and other-owned area)
|
|
||||||
func(name, param)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,18 +37,14 @@ end
|
||||||
--(should be the same functions as safe_region)
|
--(should be the same functions as safe_region)
|
||||||
--also check for permission when region is set?
|
--also check for permission when region is set?
|
||||||
worldedit.can_edit_volume = function(name, pos1, pos2)
|
worldedit.can_edit_volume = function(name, pos1, pos2)
|
||||||
--old you-can-worldedit-everything behaviour
|
--old you-can-worldedit-everything behaviour.
|
||||||
if not PROTECTION_MOD_EXISTS then
|
if not PROTECTION_MOD_EXISTS or minetest.check_player_privs(name, {areas=true}) then
|
||||||
--then if you were able to run this command, then you have the worldedit privilege.
|
--If there's no mod, worldedit.privs already required that you have the worldedit privilege,then if you were able to run this command, then you have the worldedit privilege.
|
||||||
|
--Or, you can set areas, so you are allowed to worldedit them too. The ability to set the whole world as owned by yourself is already potentially destructive, what's more destructive capability?
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
--new ownership-based behaviour
|
--new ownership-based behaviour
|
||||||
|
|
||||||
--You can set areas, so you can worldedit them too.
|
|
||||||
if minetest.check_player_privs(name, {areas=true}) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[I need to use a special per-command region (think /stack, or even worse, /move), the same one safe_region uses, but corner points instead of count... instead of a for loop interpolating between pos1 and pos2]]--
|
--[[I need to use a special per-command region (think /stack, or even worse, /move), the same one safe_region uses, but corner points instead of count... instead of a for loop interpolating between pos1 and pos2]]--
|
||||||
|
|
||||||
--all-or-nothing here
|
--all-or-nothing here
|
||||||
|
|
Loading…
Reference in New Issue