add chatmode/notification rumble

This commit is contained in:
Li0n 2022-02-26 18:47:57 +01:00
parent 8f13ab0792
commit 451861643a
1 changed files with 37 additions and 4 deletions

View File

@ -8,12 +8,17 @@ local rumble_duration_max_standard = 5
-- To do list: -- To do list:
-- sadist mode -- sadist mode
-- tnt griefer 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) -- chat mode: trigger from specific words written by either yourself (humiliation) or others (degradation)
local rumble_strength_max = rumble_strength_max_standard local rumble_strength_max = rumble_strength_max_standard
local rumble_duration_max = rumble_duration_max_standard local rumble_duration_max = rumble_duration_max_standard
local log local log
local log_mode local log_mode
local local_player_name
local chatmode
local log_only = function(text) local log_only = function(text)
minetest.log("action", 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!") minetest.display_chat_message("rumble mod loaded. May the rumble be with you!")
log = log_and_chat log = log_and_chat
log_mode = "log and chat" log_mode = "log and chat"
chatmode = off
end) end)
-- step 2 (take damage) -- step 2 (take damage)
@ -53,9 +59,12 @@ end)
-- step 5 (chat mode) -- step 5 (chat mode)
minetest.register_on_receiving_chat_message(function(message) minetest.register_on_receiving_chat_message(function(message)
if (string.match((message), "^.*the.*$")) then 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") log("[rumble] queue 0.2 5")
end end
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 strength: "..rumble_strength_max)
minetest.display_chat_message("max rumble duration: "..rumble_duration_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("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, end,
}) })
-- command 4 -- command 4
minetest.register_chatcommand("chat_off", { minetest.register_chatcommand("chatlog_off", {
description = "disables rumble logs being written into chat", description = "disables rumble logs being written into chat",
func = function() func = function()
log = log_only log = log_only
@ -108,7 +123,7 @@ minetest.register_chatcommand("chat_off", {
}) })
-- command 5 -- command 5
minetest.register_chatcommand("chat_on", { minetest.register_chatcommand("chatlog_on", {
description = "enables rumble logs being written into chat", description = "enables rumble logs being written into chat",
func = function() func = function()
log = log_and_chat log = log_and_chat
@ -136,3 +151,21 @@ minetest.register_chatcommand("resume", {
minetest.display_chat_message("rumble logging resumed") minetest.display_chat_message("rumble logging resumed")
end, 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,
})