summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2019-05-25 19:23:47 -0500
committercheapie <no-email-for-you@example.com>2019-05-25 19:23:47 -0500
commite744e27e6539f7f895d172f841ccb4eee4a82c68 (patch)
treea7234888dad1dec74650576bdc148d9d70415365
parente45d2bc3312324fbef51b809e827dbc8e0433671 (diff)
downloadnewplayer-e744e27e6539f7f895d172f841ccb4eee4a82c68.tar
newplayer-e744e27e6539f7f895d172f841ccb4eee4a82c68.tar.gz
newplayer-e744e27e6539f7f895d172f841ccb4eee4a82c68.tar.bz2
newplayer-e744e27e6539f7f895d172f841ccb4eee4a82c68.tar.xz
newplayer-e744e27e6539f7f895d172f841ccb4eee4a82c68.zip
Allow extra privs to be granted along with interact
-rw-r--r--README3
-rw-r--r--init.lua6
2 files changed, 8 insertions, 1 deletions
diff --git a/README b/README
index d1ddae9..8bb038a 100644
--- a/README
+++ b/README
@@ -2,10 +2,11 @@ newplayer
=========
This mod adds a form containing the rules that is shown to players without interact when they join. They are also teleported to a special spawn point designated for players without interact.
-If they press "I agree", they are teleported to the normal spawn. The /spawn command will also take them back there (or to the non-interact spawn if they don't have interact).
+If they press "I agree", they are teleported to the normal spawn and interact is granted. The /spawn command will also take them back there (or to the non-interact spawn if they don't have interact).
If they press "I do not agree", they are allowed to play normally (but without interact), although bright red text will be placed in the middle of the screen explaining the situation.
At any point, the /rules command will show the rules. The /set_interact_spawn and /set_no_interact_spawn commands (requiring the server priv) will set the respective spawn point to your current location.
To set the rules, either place a file called "newplayer-rules.txt" in the world directory, press the "Edit" button at the rules screen, or use the /editrules command (the latter two methods require the "server" priv). If this file does not exist, the mod will tell you where to create it if you attempt to view the rules.
+To cause more privileges than just interact to be granted, set the setting newplayer.extra_privs to a space-delimited list of the extra privs you want.
If one or more keywords are set (Use /getkeywords to see them, /addkeyword to add one, or /delkeyword to remove one, all three require server privs.), then players will have to enter a randomly-chosen entry from the list into a provided text box before clicking the agree button. It is then possible to put the string "@KEYWORD" in the rules, which will be replaced with the chosen keyword when they are shown to a player without interact. This substitution (intentionally) does not occur when the rules are being shown to somebody with interact (for example, if they use the /rules command because they want to re-read them)* so that they can't see the keyword, preventing them from telling other players what it is... or what they think it is, since the other player will likely have a different keyword assuming several are set.
If a keyword is not set, players are not asked for it and simply pressing the "I agree" button is enough.
diff --git a/init.lua b/init.lua
index 8848e76..57d162d 100644
--- a/init.lua
+++ b/init.lua
@@ -134,6 +134,12 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
if #newplayer.keywords == 0 or (not newplayer.assigned_keywords[name]) or string.lower(fields.keyword) == string.lower(newplayer.assigned_keywords[name]) then
local privs = minetest.get_player_privs(name)
privs.interact = true
+ local extraprivs = minetest.settings:get("newplayer.extra_privs")
+ if extraprivs then
+ for i in string.gmatch(extraprivs,"%S+") do
+ privs[i] = true
+ end
+ end
minetest.set_player_privs(name,privs)
if newplayer.hudids[name] then
minetest.get_player_by_name(name):hud_remove(newplayer.hudids[name])