Compare commits

4 Commits

6 changed files with 70 additions and 33 deletions

View File

@ -1,5 +1,7 @@
interact = {}
interact.configured = false --Change this to true when you've configured the mod!
--Which screens to show.
interact.screen1 = true --The welcome a first question screen.
interact.screen2 = true --The visit or interact screen.
@ -43,8 +45,9 @@ interact.s3_b2 = "I disagree"
--The message to send players who disagree when they are kicked for disagring with the rules.
interact.disagree_msg = "Bye then! You have to agree to the rules to play on the server."
--Kick or ban players who disagree with the rules. False will just kick.
interact.disagree_ban = false
--Kick, ban or ignore players who disagree with the rules.
--Options are "kick" "ban" "nothing"
interact.disagree_action = "kick"
--The fouth screen--
--Should there be a back to rules button?

3
description.txt Normal file
View File

@ -0,0 +1,3 @@
A mod that gives the interact priv to players who want it.
It displays the rules, and then provides a simple quiz on them.
If the player completes the quiz sucsesfully, then s/he is given interact.

View File

@ -63,17 +63,27 @@ local function make_formspec4(player)
return table.concat(size)
end
local server_formspec = "size[10,4]" ..
"label[0.5,0.5;Hey, you! Yes, you, the admin! What do you think you're doing]" ..
"label[0.5,0.9;ignoring warnings in the terminal? You should watch it carefully!]" ..
"label[0.5,1.5;Before you do anything else, open rules.lua in the interact mod]" ..
"label[0.5,1.9;and put your rules there. Then, open config.lua, and look at the]" ..
"label[0.5,2.3;settings. Configure them so that they match up with your rules.]" ..
"label[0.5,2.7;Then, set interact.configured to true, and this message will go away]" ..
"label[0.5,3.1;once you've restarted the server.]" ..
"label[0.5,3.6;Thank you!]"
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "welcome" then return end
if formname ~= "interact_welcome" then return end
local name = player:get_player_name()
if fields.no then
if interact.screen2 == false then
minetest.after(1, function()
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end)
else
minetest.after(1, function()
minetest.show_formspec(name, "visit", make_formspec2(player))
minetest.show_formspec(name, "interact_visit", make_formspec2(player))
end)
end
return
@ -88,11 +98,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "visit" then return end
if formname ~= "interact_visit" then return end
local name = player:get_player_name()
if fields.interact then
minetest.after(1, function()
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end)
return
elseif fields.visit then
@ -104,7 +114,7 @@ end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "rules" then return end
if formname ~= "interact_rules" then return end
local name = player:get_player_name()
if fields.accept then
if interact.screen4 == false then
@ -118,26 +128,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
else
minetest.after(1, function()
minetest.show_formspec(name, "quiz", make_formspec4(player))
minetest.show_formspec(name, "interact_quiz", make_formspec4(player))
end)
end
return
elseif fields.decline then
if interact.disagree_ban ~= true then
if interact.disagree_action == "kick" then
minetest.kick_player(name, interact.disagree_msg)
else
elseif interact.disagree_action == "ban" then
minetest.ban_player(name)
else
minetest.chat_send_player(name, interact.disagree_msg)
end
return
end
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "quiz" then return end
if formname ~= "interact_quiz" then return end
local name = player:get_player_name()
if fields.rules then
minetest.after(1, function()
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end)
return
end
@ -180,12 +192,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif interact.on_wrong_quiz == "reshow" then
minetest.chat_send_player(name, interact.quiz_try_again_msg)
minetest.after(1, function()
minetest.show_formspec(name, "quiz", make_formspec4(player))
minetest.show_formspec(name, "interact_quiz", make_formspec4(player))
end)
elseif interact.on_wrong_quiz == "rules" then
minetest.chat_send_player(name, interact.quiz_rules_msg)
minetest.after(1, function()
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end)
else
minetest.chat_send_player(name, interact.quiz_fail_msg)
@ -201,15 +213,15 @@ minetest.register_chatcommand("rules",{
local player = minetest.get_player_by_name(name)
if interact.screen1 ~= false then
minetest.after(1, function()
minetest.show_formspec(name, "welcome", make_formspec(player))
minetest.show_formspec(name, "interact_welcome", make_formspec(player))
end)
elseif interact.screen2 ~= false then
minetest.after(1, function()
minetest.show_formspec(name, "visit", make_formspec2(player))
minetest.show_formspec(name, "interact_visit", make_formspec2(player))
end)
else
minetest.after(1, function()
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end)
end
end
@ -219,13 +231,17 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
if not minetest.get_player_privs(name).interact then
if interact.screen1 ~= false then
minetest.show_formspec(name, "welcome", make_formspec(player))
minetest.show_formspec(name, "interact_welcome", make_formspec(player))
elseif interact.screen2 ~= false then
minetest.show_formspec(name, "visit", make_formspec2(player))
minetest.show_formspec(name, "interact_visit", make_formspec2(player))
else
minetest.show_formspec(name, "rules", make_formspec3(player))
minetest.show_formspec(name, "interact_rules", make_formspec3(player))
end
else
elseif minetest.get_player_privs(name).server and interact.configured == false then
minetest.show_formspec(name, "interact_no_changes_made", server_formspec)
end
end
)
end)
if not interact.configured then
minetest.log("warning", "Mod \"Interact\" has not been configured! Please open config.lua in its folder and configure it. See the readme of the mod for more details.")
end

View File

@ -1,13 +1,21 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
The MIT License (MIT)
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Copyright (c) 2015 Amaz
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
0. You just DO WHAT THE FUCK YOU WANT TO.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

7
mod.conf Normal file
View File

@ -0,0 +1,7 @@
name = interact
title = Interact
author = Amaz
description = A mod that gives the interact priv to players who want it and who have agreed to the rules.
license = MIT
forum = https://forum.minetest.net/viewtopic.php?f=11&t=11200
version = 1.0

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB