mirror of
https://github.com/minetest-mods/moreblocks.git
synced 2025-07-03 08:30:40 +02:00
tweak some things
This commit is contained in:
@ -10,22 +10,20 @@ local function on_priv_change(name)
|
||||
end
|
||||
end
|
||||
|
||||
local function override_on_priv_change(old)
|
||||
return function(name, cause)
|
||||
on_priv_change(name)
|
||||
if old then
|
||||
old(name, cause)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.registered_privileges[priv] then
|
||||
local def = minetest.registered_privileges[priv]
|
||||
local old_on_grant = def.on_grant
|
||||
local old_on_revoke = def.on_revoke
|
||||
def.on_grant = function(name, cause)
|
||||
on_priv_change(name)
|
||||
if old_on_grant then
|
||||
old_on_grant(name, cause)
|
||||
end
|
||||
end
|
||||
def.on_revoke = function(name, cause)
|
||||
on_priv_change(name)
|
||||
if old_on_revoke then
|
||||
old_on_revoke(name, cause)
|
||||
end
|
||||
end
|
||||
def.on_grant = override_on_priv_change(def.on_grant)
|
||||
def.on_revoke = override_on_priv_change(def.on_revoke)
|
||||
|
||||
else
|
||||
minetest.register_privilege(priv, {
|
||||
description = "Allow use of the circular saw in inventory",
|
||||
@ -38,20 +36,9 @@ end
|
||||
|
||||
if minetest.registered_privileges[creative_priv] then
|
||||
local def = minetest.registered_privileges[creative_priv]
|
||||
local old_on_grant = def.on_grant
|
||||
local old_on_revoke = def.on_revoke
|
||||
def.on_grant = function(name, cause)
|
||||
on_priv_change(name)
|
||||
if old_on_grant then
|
||||
old_on_grant(name, cause)
|
||||
end
|
||||
end
|
||||
def.on_revoke = function(name, cause)
|
||||
on_priv_change(name)
|
||||
if old_on_revoke then
|
||||
old_on_revoke(name, cause)
|
||||
end
|
||||
end
|
||||
def.on_grant = override_on_priv_change(def.on_grant)
|
||||
def.on_revoke = override_on_priv_change(def.on_revoke)
|
||||
|
||||
else
|
||||
minetest.register_privilege(creative_priv, {
|
||||
description = "Allow use of the inventory saw creatively",
|
||||
|
Reference in New Issue
Block a user