From 5a74d6efaa4358b7ccf55bfcdf050cd431cf72cd Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Sat, 6 Nov 2021 10:35:36 +0100 Subject: [PATCH] Privileges --- init.lua | 1 + privs.lua | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 privs.lua diff --git a/init.lua b/init.lua index 8393bb5..d4a50cf 100644 --- a/init.lua +++ b/init.lua @@ -21,6 +21,7 @@ yl_template.information.name = "yl_template" yl_template.information.additional = "Additional information" dofile(yl_template.modpath .. "config.lua") +dofile(yl_template.modpath .. "privs.lua") dofile(yl_template.modpath .. "internal.lua") dofile(yl_template.modpath .. "api.lua") dofile(yl_template.modpath .. "distinct_feature.lua") diff --git a/privs.lua b/privs.lua new file mode 100644 index 0000000..d6c3cb3 --- /dev/null +++ b/privs.lua @@ -0,0 +1,30 @@ +local name = "Name of the priv" +local definition = { + description = "Can do ...", + -- 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) + 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) + 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(name, definition)