From 6c554b8def07644b7e2ef8deb81162533f1a22b9 Mon Sep 17 00:00:00 2001 From: melzua Date: Tue, 9 Feb 2016 19:43:51 +0100 Subject: [PATCH] Set player privs correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, you loose all the previous privs and get only interact when push the Ok button. Also the 'true' in ‘return true’ makes the other register_on_player_receive_fields unusable (for example, the inventory form). --- mods/welcome/init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mods/welcome/init.lua b/mods/welcome/init.lua index a85ecd4..1ef89ac 100644 --- a/mods/welcome/init.lua +++ b/mods/welcome/init.lua @@ -53,13 +53,15 @@ end minetest.register_on_player_receive_fields( function(player, form_name, fields) local name = player:get_player_name() + local privs = minetest.get_player_privs(name) - if minetest.check_player_privs(name, {interact = true}) or fields.rules then - return true + if privs.interact or fields.rules then + return end if fields.accept_rules then - minetest.set_player_privs(name, {interact = true}) + privs.interact = true + minetest.set_player_privs(name, privs) minetest.chat_send_player(name, "You now have interact, follow the rules and have fun!") else minetest.chat_send_player(name, "If you want to interact, please read and accept the rules. Type /welcome to show rules.") @@ -84,4 +86,4 @@ minetest.register_on_joinplayer( end end) -default.log("mod:welcome", "loaded") \ No newline at end of file +default.log("mod:welcome", "loaded")