59 lines
1.8 KiB
Lua
59 lines
1.8 KiB
Lua
local priv_name = "example"
|
|
local priv_definition = {
|
|
description = "Can do example task",
|
|
-- Privilege description
|
|
|
|
give_to_singleplayer = false,
|
|
-- Whether to grant the privilege to singleplayer.
|
|
|
|
give_to_admin = true,
|
|
-- Whether to grant the privilege to the server admin.
|
|
-- Uses value of 'give_to_singleplayer' by default.
|
|
|
|
on_grant = function(name, granter_name)
|
|
-- logging
|
|
if not granter_name then
|
|
granter_name = "MOD"
|
|
end
|
|
if not name then
|
|
name = "ERROR"
|
|
end
|
|
if not priv_name then
|
|
priv_name = "ERROR"
|
|
end
|
|
core.log(
|
|
"action",
|
|
"[MOD] yl_template: User " .. granter_name .. " granted user " .. name .. " priv " .. priv_name
|
|
)
|
|
end,
|
|
-- Called when given to player 'name' by 'granter_name'.
|
|
-- 'granter_name' will be nil if the priv was granted by a mod.
|
|
|
|
on_revoke = function(name, revoker_name)
|
|
-- logging
|
|
if not revoker_name then
|
|
revoker_name = "MOD"
|
|
end
|
|
if not name then
|
|
name = "ERROR"
|
|
end
|
|
if not priv_name then
|
|
priv_name = "ERROR"
|
|
end
|
|
core.log(
|
|
"action",
|
|
"[MOD] yl_template: User " .. revoker_name .. " revoked user " .. name .. " priv " .. priv_name
|
|
)
|
|
end
|
|
-- Called when taken from player 'name' by 'revoker_name'.
|
|
-- 'revoker_name' will be nil if the priv was revoked by a mod.
|
|
|
|
-- Note that the above two callbacks will be called twice if a player is
|
|
-- responsible, once with the player name, and then with a nil player
|
|
-- name.
|
|
-- Return true in the above callbacks to stop register_on_priv_grant or
|
|
-- revoke being called.
|
|
}
|
|
|
|
minetest.register_privilege(priv_name, priv_definition)
|