From 451861643a1a7b961fc88ffe0069a0eb2f087e22 Mon Sep 17 00:00:00 2001 From: Li0n Date: Sat, 26 Feb 2022 18:47:57 +0100 Subject: [PATCH] add chatmode/notification rumble --- init.lua | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 9e8bac8..dc10633 100644 --- a/init.lua +++ b/init.lua @@ -8,12 +8,17 @@ local rumble_duration_max_standard = 5 -- To do list: -- sadist mode -- tnt griefer mode +-- log player name only once, after player is initialized. +-- editable table of words to trigger chatmode +-- command to choose which word triggers rumble -- chat mode: trigger from specific words written by either yourself (humiliation) or others (degradation) local rumble_strength_max = rumble_strength_max_standard local rumble_duration_max = rumble_duration_max_standard local log local log_mode +local local_player_name +local chatmode local log_only = function(text) minetest.log("action", text) @@ -32,6 +37,7 @@ minetest.register_on_mods_loaded(function() minetest.display_chat_message("rumble mod loaded. May the rumble be with you!") log = log_and_chat log_mode = "log and chat" + chatmode = off end) -- step 2 (take damage) @@ -53,8 +59,11 @@ end) -- step 5 (chat mode) minetest.register_on_receiving_chat_message(function(message) - if (string.match((message), "^.*the.*$")) then - log("[rumble] queue 0.2 5") + if chatmode == true and (string.match((message), "^.*<.*>.*$")) and minetest.localplayer ~= nil then + local_player_name = minetest.localplayer:get_name(self) + if not (string.match((message), "^.*"..local_player_name..".*$")) then + log("[rumble] queue 0.2 5") + end end end) @@ -94,11 +103,17 @@ minetest.register_chatcommand("settings", { minetest.display_chat_message("max rumble strength: "..rumble_strength_max) minetest.display_chat_message("max rumble duration: "..rumble_duration_max) minetest.display_chat_message("current chat and log mode: "..log_mode) + minetest.display_chat_message("local player name: "..tostring(local_player_name)) + if chatmode == true then + minetest.display_chat_message("chatmode on") + elseif chatmode == false then + minetest.display_chat_message("chatmode off") + end end, }) -- command 4 -minetest.register_chatcommand("chat_off", { +minetest.register_chatcommand("chatlog_off", { description = "disables rumble logs being written into chat", func = function() log = log_only @@ -108,7 +123,7 @@ minetest.register_chatcommand("chat_off", { }) -- command 5 -minetest.register_chatcommand("chat_on", { +minetest.register_chatcommand("chatlog_on", { description = "enables rumble logs being written into chat", func = function() log = log_and_chat @@ -136,3 +151,21 @@ minetest.register_chatcommand("resume", { minetest.display_chat_message("rumble logging resumed") end, }) + +-- command 8 +minetest.register_chatcommand("chatmode_on", { + description = "turns on chatmode: triggers rumble for every received message", + func = function(text) + chatmode = true + minetest.display_chat_message("chatmode on") + end, +}) + +-- command 9 +minetest.register_chatcommand("chatmode_off", { + description = "turns off chatmode: triggers rumble for every received message", + func = function(text) + chatmode = false + minetest.display_chat_message("chatmode off") + end, +})