From ea8fa0f2f2d60aafa77f5db141c47f25506471bf Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Sat, 6 Nov 2021 10:58:44 +0100 Subject: [PATCH] Format --- priv_example.lua | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/priv_example.lua b/priv_example.lua index 9d80bfb..75392cc 100644 --- a/priv_example.lua +++ b/priv_example.lua @@ -1,5 +1,5 @@ -local name = "example" -local definition = { +local priv_name = "example" +local priv_definition = { description = "Can do example task", -- Privilege description @@ -11,11 +11,39 @@ local definition = { -- 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. @@ -27,4 +55,4 @@ local definition = { -- revoke being called. } -minetest.register_privilege(name, definition) +minetest.register_privilege(priv_name, priv_definition)