From 45a6ee6c4c71ddccb6ec81cf7b5e8f427e0ae24b Mon Sep 17 00:00:00 2001 From: Baigle <80816259+Baigle@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:31:31 +0000 Subject: [PATCH 1/5] Clarification --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e746761..0162c45 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # colour_chat A minetest CSM mod for changing the colour of text sent to the server. +### Installing +See https://wiki.minetest.net/Installing_Client-Side_Mods and https://forum.minetest.net/viewtopic.php?t=17830 for installing and then enabling client-side mods via the use of the mods.conf configuration file. + ### Usage -Use .set_colour to set the colour of chat sent to the server, you can use either HTML named colours or HTML hexdecimal colour codes. Use .rainbow to generate rainbow text +Use ".help all" after enabling client side modding in the Minetest settings to see all loaded client side mod commands. +Use .set_colour to set the colour of chat sent to the server, you can use either HTML named colours or HTML hexdecimal colour codes. +Use .rainbow to generate rainbow text, and its .rainbow_smooth variants to adjust how the color-shift messages appear. From b817a9cbf2a23afd96edd44dd30574a7756f0a35 Mon Sep 17 00:00:00 2001 From: Baigle <80816259+Baigle@users.noreply.github.com> Date: Sat, 5 Feb 2022 13:35:30 +0000 Subject: [PATCH 2/5] Getting my fork up to date for some reason my pull request did not automatically update my fork, instead only pushing it to the main project. --- init.lua | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 175 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index e3c82bf..3993742 100644 --- a/init.lua +++ b/init.lua @@ -61,7 +61,7 @@ end local function say(message) if not canTalk() then - minetest.display_chat_message("You need 'shout' in order to talk") + minetest.display_chat_message("You need 'shout' in order to talk.") return end minetest.send_chat_message(message) @@ -75,13 +75,37 @@ register_on_message(function(message) if message:sub(1,1) == "/" or modstorage:get_string("colour") == "" or modstorage:get_string("colour") == "white" then return false end - - say(core.get_color_escape_sequence(modstorage:get_string("colour")) .. message) +-- using commit https://github.com/red-001/colour_chat/pull/3/files from Lejo1 + local atname, msg=string.match(message, "^@([^%s:]*)[%s:](.*)") + if atname and msg then message = msg end + if modstorage:get_string("colour") == "rainbow" then + local step = 360 / message:len() + local hue = 0 + -- iterate the whole 360 degrees + local output = "" + for i = 1, message:len() do + local char = message:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + if atname and msg then + say("@"..atname .." ".. output) + else say(output) + end + elseif atname and msg then + say("@"..atname .." ".. core.colorize(modstorage:get_string("colour"), message)) + else + say(core.get_color_escape_sequence(modstorage:get_string("colour")) .. message) + end return true end) core.register_chatcommand("set_colour", { - description = core.gettext("Change chat colour"), + description = core.gettext("Change default session sent chat colour."), func = function(colour) modstorage:set_string("colour", colour) return true, "Chat colour changed." @@ -89,10 +113,10 @@ core.register_chatcommand("set_colour", { }) core.register_chatcommand("rainbow", { - description = core.gettext("rainbow text"), + description = core.gettext("Abrupt rainbow text transition."), func = function(param) if not canTalk() then - return false, "You need 'shout' in order to use this command" + return false, "You need 'shout' in order to use this command." end local step = 360 / param:len() local hue = 0 @@ -112,8 +136,152 @@ core.register_chatcommand("rainbow", { end, }) +core.register_chatcommand("rainbow_smooth", { + description = core.gettext("Smooth rainbow text from red."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 0 + -- iterate 1/4 of 360 degrees (default 360) + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + +core.register_chatcommand("rainbow_smooth_yellow", { + description = core.gettext("Smooth rainbow text from yellow."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 60 + -- iterate 1/4 of 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + +core.register_chatcommand("rainbow_smooth_green", { + description = core.gettext("Smooth rainbow text from green."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 120 + -- iterate 1/4 of 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + +core.register_chatcommand("rainbow_smooth_cyan", { + description = core.gettext("Smooth rainbow text from cyan."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 170 + -- iterate 1/4 of 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + +core.register_chatcommand("rainbow_smooth_blue", { + description = core.gettext("Smooth rainbow text from blue."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 240 + -- iterate 1/4 of 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + +core.register_chatcommand("rainbow_smooth_purple", { + description = core.gettext("Smooth rainbow text from purple/pink."), + func = function(param) + if not canTalk() then + return false, "You need 'shout' in order to use this command." + end + local step = 90 / param:len() + local hue = 300 + -- iterate 1/4 of 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + say(output) + return true +end, +}) + core.register_chatcommand("say", { - description = core.gettext("Send text without applying colour to it"), + description = core.gettext("Send text without configured color characters appended."), func = function(text) say(text) return true From 614c613b0d53b62eba8724b3a9ce5828a381772f Mon Sep 17 00:00:00 2001 From: Baigle <80816259+Baigle@users.noreply.github.com> Date: Sat, 5 Feb 2022 14:43:27 +0000 Subject: [PATCH 3/5] change step rate for .set_colour rainbow --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 3993742..9fce98b 100644 --- a/init.lua +++ b/init.lua @@ -79,7 +79,7 @@ register_on_message(function(message) local atname, msg=string.match(message, "^@([^%s:]*)[%s:](.*)") if atname and msg then message = msg end if modstorage:get_string("colour") == "rainbow" then - local step = 360 / message:len() + local step = 90 / message:len() local hue = 0 -- iterate the whole 360 degrees local output = "" From 428b3cf37ab04a910a6bed5ed62ac256a0623eb5 Mon Sep 17 00:00:00 2001 From: Baigle <80816259+Baigle@users.noreply.github.com> Date: Sun, 6 Feb 2022 15:09:29 +0000 Subject: [PATCH 4/5] Add mod.conf file for 5.5.0 deprecation --- mod.conf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 mod.conf diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..871c0fd --- /dev/null +++ b/mod.conf @@ -0,0 +1,5 @@ +name = colour_chat +release = 1.01 +author = red-001, Lejo1, Baigle +description = A minetest CSM mod for changing the colour of text sent to the server. +title = Colored Sent Chat Messages From d8fd9743495f6482b5de737bcffeddc625e63741 Mon Sep 17 00:00:00 2001 From: Baigle <80816259+Baigle@users.noreply.github.com> Date: Thu, 26 May 2022 10:48:26 +0000 Subject: [PATCH 5/5] Added installation instructions most players used this video and mod instead of this one, so i added it as an alternative --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0162c45..21fa4f2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ A minetest CSM mod for changing the colour of text sent to the server. ### Installing See https://wiki.minetest.net/Installing_Client-Side_Mods and https://forum.minetest.net/viewtopic.php?t=17830 for installing and then enabling client-side mods via the use of the mods.conf configuration file. +### Alternative CSM Mod Installation Instructions (YouTube, unverified code) +See https://www.youtube.com/watch?v=GaYVTnmjajI for the older 2020 variety chat color mod. + ### Usage Use ".help all" after enabling client side modding in the Minetest settings to see all loaded client side mod commands. Use .set_colour to set the colour of chat sent to the server, you can use either HTML named colours or HTML hexdecimal colour codes.