diff --git a/Readme.md b/Readme.md index 73d9e6e..f177781 100644 --- a/Readme.md +++ b/Readme.md @@ -1,19 +1,16 @@ ##Interact: A mod for minetest. This mod is designed to automatically grant new players on a server interact. A formspec will be show when the player joins, and there is a command to bring the formspec up later in the game. -There are 3 screens that they go through. The first one is a check if they like griefing (One for really stupid griefers!), the next checks if the player just wants to look round the server, and the final one shows the rules, and asks the player to accept them. +There are 3 screens that they go through. The first one is a check if they like griefing (One for really stupid griefers!), the next checks if the player just wants to look round the server, and the final one shows the rules, and asks the player to accept them. + +Almost everything in the mod can be configured to how you want it. ####Configuring the mod: -By default, the rules are blank. Thus, you will need to open up init.lua, and add your rules on line 3. If you grant fast by default on your server, you may want to replace shout with fast on line 86. You can also edit the various lines to suit your server. Lines that contain things that control the messages are these: +You will probably want to replace the default rules with your own in rules.lua. -- 9 & 10 -- 19 & 20 -- 43 -- 57 -- 69 & 70 -- 78 +Everything else that you need to configure the mod can be found in config.lua. If you want to, have a look over it before running the mod, to see if everything seems to be as you want it! ####Notes: -1. This mod is based on the (old) [rules](https://github.com/CraigyDavi/Craig-Server_game/blob/df8beb15e6b02ab6dd22f94349453c51819238c4/mods/_misc/rules.lua) on [Craig's Server.](https://forum.minetest.net/viewtopic.php?f=10&t=7010) -2. That mod was, in turn based on this [mod.](https://github.com/ChaosWormz/mt_terms_of_use) -3. It is quite likely that I will make what is said to the user configurable without having to edit init.lua, at some point. \ No newline at end of file +1. This mod is based on the (old) [rules](https://github.com/CraigyDavi/Craig-Server_game/blob/df8beb15e6b02ab6dd22f94349453c51819238c4/mods/_misc/rules.lua) on [Craig's Server.](https://forum.minetest.net/viewtopic.php?f=10&t=7010) +2. That mod was, in turn based on this [mod.](https://github.com/ChaosWormz/mt_terms_of_use) +3. I may add randomly selected messages at some point. diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..fa7ff1a --- /dev/null +++ b/config.lua @@ -0,0 +1,49 @@ +interact = {} + +--The first screen-- +--The text at the top. +interact.s1_header = "Hello, welcome to this server!" +--Lines one and two. Make sure each line is less than 70 characters, or they will run off the screen. +interact.s1_l2 = "Could you please tell me if you like to grief or not?" +interact.s1_l3 = "" +--The buttons. Each can have 15 characters, max. +interact.s1_b1 = "No, I don't." +interact.s1_b2 = "Yes, I do!" + +--The message to send kicked griefers. +interact.msg_grief = "Try out singleplayer if you like griefing, because then you'll only destroy your own stuff!" + +--Ban or kick griefers? Default is kick, set to true for ban. +interact.grief_ban = false + +--The second screen-- +--Lines one and two. Make sure each line is less than 70 characters, or they will run off the screen. +interact.s2_l1 = "So, do you want interact, or do you just want to look around" +interact.s2_l2 = "the server?" +--The buttons. These ones can have a maximum of 26 characters. +interact.s2_b1 = "Yes, I want interact!" +interact.s2_b2 = "I just want to look round." + +--The message the player is sent if s/he is just visting. +interact.vist_msg = "Have a nice time looking round! If you want interact just type /rules, and you can go through the process again!" + +--The third screen-- +--The header for the rules box, this can have 60 characters, max. +interact.s3_header = "Here are the rules:" + +--The buttons. Each can have 15 characters, max. +interact.s3_b1 = "I agree" +interact.s3_b2 = "I disagree" + +--The message to send players who disagree when they are kicked. +interact.disagree_msg = "Bye then! You have to agree to the rules to play on the server." + +--Kick or ban players who disagree. False will just kick. +interact.disagree_ban = false + +--The messages send to the player after interact is granted. +interact.interact_msg1 = "Thanks for accepting the rules, you now are able to interact with things." +interact.interact_msg2 = "Happy building!" + +--The priv required to use the /rules command. +interact.priv = {fast = true} diff --git a/init.lua b/init.lua index ad4086a..b1eec55 100644 --- a/init.lua +++ b/init.lua @@ -1,33 +1,32 @@ -local RULES = [[ -Rules: - -]] +dofile(minetest.get_modpath("interact") .. "/config.lua") +dofile(minetest.get_modpath("interact") .. "/rules.lua") --I put the rules in their own file so that they don't get lost/overlooked! local function make_formspec(player) local name = player:get_player_name() local size = { "size[10,4]" } - table.insert(size, "label[0.5,0.5;Hello, " ..name.. ", welcome to this server!]") - table.insert(size, "label[0.5,1.5;Could you please tell me if you like to grief or not?]") - table.insert(size, "button_exit[5.5,3.4;2,0.5;no;No, I don't.]") - table.insert(size, "button[7.5,3.4;2,0.5;yes;Yes, I do!]") + table.insert(size, "label[0.5,0.5;" ..interact.s1_header.. "]") + table.insert(size, "label[0.5,1.5;" ..interact.s1_l2.. "]") + table.insert(size, "label[0.5,2;" ..interact.s1_l3.. "]") + table.insert(size, "button_exit[5.5,3.4;2,0.5;no;" ..interact.s1_b1.. "]") + table.insert(size, "button[7.5,3.4;2,0.5;yes;" ..interact.s1_b2.. "]") return table.concat(size) end local function make_formspec2(player) local name = player:get_player_name() local size = { "size[10,4]" } - table.insert(size, "label[0.5,0.5;So " ..name.. ", do you want interact, or do you just want to look around]") - table.insert(size, "label[0.5,1;the server?]") - table.insert(size, "button_exit[2.5,3.4;3.5,0.5;interact;Yes, I want interact!]") - table.insert(size, "button_exit[6.4,3.4;3.6,0.5;visit;I just want to look round.]") + table.insert(size, "label[0.5,0.5;" ..interact.s2_l1.. "]") + table.insert(size, "label[0.5,1;" ..interact.s2_l2.. "]") + table.insert(size, "button_exit[2.5,3.4;3.5,0.5;interact;" ..interact.s2_b1.. "]") + table.insert(size, "button_exit[6.4,3.4;3.6,0.5;visit;" ..interact.s2_b2.. "]") return table.concat(size) end local function make_formspec3(player) local size = { "size[10,8]" } - table.insert(size, "textarea[0.5,0.5;9.5,7.5;TOS;Here are the rules:;"..RULES.."]") - table.insert(size, "button[5.5,7.4;2,0.5;decline;I Disagree]") - table.insert(size, "button_exit[7.5,7.4;2,0.5;accept;I Agree]") + table.insert(size, "textarea[0.5,0.5;9.5,7.5;TOS;" ..interact.s3_header.. ";" ..interact.rules.. "]") + table.insert(size, "button[5.5,7.4;2,0.5;decline;" ..interact.s3_b2.. "]") + table.insert(size, "button_exit[7.5,7.4;2,0.5;accept;" ..interact.s3_b1.. "]") return table.concat(size) end @@ -40,7 +39,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) return elseif fields.yes then - minetest.kick_player(name, "Try out singleplayer if you like griefing, because then you'll only destroy your own stuff!") + if interact.grief_ban ~= true then + minetest.kick_player(name, interact.msg_grief) + else + minetest.ban_player(name) + end return end end) @@ -54,7 +57,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) return elseif fields.visit then - minetest.chat_send_player(name, "Have a nice time looking round! If you want interact just type /rules, and you can go through the process again!") + minetest.chat_send_player(name, interact.vist_msg) minetest.log("action", name.. " is just visiting.") return end @@ -65,9 +68,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "rules" then return end local name = player:get_player_name() if fields.accept then - if minetest.check_player_privs(name, {shout=true}) then - minetest.chat_send_player(name, "Thanks for accepting the rules, you now are able to interact with things.") - minetest.chat_send_player(name, "Happy building!") + if minetest.check_player_privs(name, interact.priv) then + minetest.chat_send_player(name, interact.interact_msg1) + minetest.chat_send_player(name, interact.interact_msg2) local privs = minetest.get_player_privs(name) privs.interact = true minetest.set_player_privs(name, privs) @@ -75,7 +78,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end return elseif fields.decline then - minetest.kick_player(name, "Bye then! You have to agree to the rules to play on the server.") + if interact.disagree_ban ~= true then + minetest.kick_player(name, interact.disagree_msg) + else + minetest.ban_player(name) + end return end end) @@ -83,7 +90,7 @@ end) minetest.register_chatcommand("rules",{ params = "", description = "Shows the server rules", - privs = {shout=true}, + privs = interact.priv, func = function (name,params) local player = minetest.get_player_by_name(name) minetest.after(1, function() @@ -100,4 +107,3 @@ minetest.register_on_joinplayer(function(player) end end ) - diff --git a/rules.lua b/rules.lua new file mode 100644 index 0000000..94d6b92 --- /dev/null +++ b/rules.lua @@ -0,0 +1,12 @@ +--The actual rules. +interact.rules = [[ +Rules: + +1. No griefing. +2. No hacked clients. +3. No swearing or insults towards other players. +4. No family roleplay. +5. No dating. +6. Do not ask for more privs, or to be an admin. Also do not ask for items. +7. PVP is not allowed. +]]