summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2016-06-10 16:28:34 -0500
committercheapie <no-email-for-you@example.com>2016-06-10 16:28:34 -0500
commite45d2bc3312324fbef51b809e827dbc8e0433671 (patch)
tree3ee78b2b2ed772eed6312af5e66e7988a456d836
parentcc4ff19bf925e9ab3b2f155dc1b83d28cbec303e (diff)
downloadnewplayer-e45d2bc3312324fbef51b809e827dbc8e0433671.tar
newplayer-e45d2bc3312324fbef51b809e827dbc8e0433671.tar.gz
newplayer-e45d2bc3312324fbef51b809e827dbc8e0433671.tar.bz2
newplayer-e45d2bc3312324fbef51b809e827dbc8e0433671.tar.xz
newplayer-e45d2bc3312324fbef51b809e827dbc8e0433671.zip
Add triggers on "help" and "rules"
-rw-r--r--README4
-rw-r--r--init.lua22
2 files changed, 26 insertions, 0 deletions
diff --git a/README b/README
index 51728e2..d1ddae9 100644
--- a/README
+++ b/README
@@ -10,5 +10,9 @@ To set the rules, either place a file called "newplayer-rules.txt" in the world
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.
+If a player without interact says anything containing the word "help" (case-insensitive), they are shown a message box explaining that they need to read the rules before they can build. If they choose to do so, the rules are shown.
+
+If a player without interact says anything containing the word "rules" (case-insensitive), they are shown the rules. This covers several types of failed attempts at using the chat command, such as "rules", "\rules", " /rules", etc.
+
* Like that ever happens.
diff --git a/init.lua b/init.lua
index 04c30aa..8848e76 100644
--- a/init.lua
+++ b/init.lua
@@ -190,6 +190,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
end
elseif formname == "newplayer:agreethanks" or formname == "newplayer:disagreewarning" then
return true
+ elseif formname == "newplayer:help" then
+ if fields.yes then
+ newplayer.showrulesform(name)
+ end
+ return true
else
return false
end
@@ -312,3 +317,20 @@ minetest.register_chatcommand("spawn",{
end
end}
)
+
+minetest.register_on_chat_message(function(name, message)
+ if minetest.check_player_privs(name,{interact=true}) then
+ return
+ end
+ if message:lower():find("rules") then
+ newplayer.showrulesform(name)
+ elseif message:lower():find("help") then
+ local fs = "size[5,3]"..
+ "label[0,0;In order to build,]"..
+ "label[0,0.5;you must read and agree to the rules.]"..
+ "label[0,1;View them now?]"..
+ "button[0,2;2,1;yes;Yes]"..
+ "button_exit[3,2;2,1;quit;No]"
+ minetest.show_formspec(name,"newplayer:help",fs)
+ end
+end)