aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua87
1 files changed, 64 insertions, 23 deletions
diff --git a/init.lua b/init.lua
index 1893f77..1248fd7 100644
--- a/init.lua
+++ b/init.lua
@@ -337,6 +337,25 @@ local function canTalk()
end
end
+
+local function get_status(ausgeben)
+ local z = true
+ local sd = modstorage:get("status")
+ if not sd then z = true
+ else z = sd == "true"
+ end
+ if ausgeben then
+ minetest.display_chat_message("colourchat is "..((get_status() and "en") or "dis").."abled\n")
+ end
+ return z
+end
+
+local function set_status(zustand)
+ modstorage:set_string("status", tostring(zustand))
+ get_status()
+end
+
+
local function say(message)
if not canTalk() then
minetest.display_chat_message("You need 'shout' in order to talk")
@@ -397,6 +416,7 @@ function fade(parameter)
end
register_on_message(function(message)
+ if not get_status() then return false end
if message:sub(1,1) == "/" or modstorage:get_string("colour") == "" or modstorage:get_string("colour") == "white" then
return false
end
@@ -526,29 +546,29 @@ end,
-core.register_chatcommand("rainbow", {
- description = core.gettext("rainbow text"),
- func = function(param)
- if not canTalk() then
- return false, "You need 'shout' in order to use this command"
- end
- local step = 360 / param:len()
- local hue = 0
- -- iterate the whole 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", {
+-- description = core.gettext("rainbow text"),
+-- func = function(param)
+-- if not canTalk() then
+-- return false, "You need 'shout' in order to use this command"
+-- end
+-- local step = 360 / param:len()
+-- local hue = 0
+-- -- iterate the whole 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"),
@@ -559,6 +579,27 @@ core.register_chatcommand("say", {
})
+core.register_chatcommand("colourchat_status", {
+ description = core.gettext("enable/disable the text colouring"),
+ func = function(text)
+ if text == "on" or text == "ein" or
+ text == "+" or text == "1" then
+ set_status(true)
+ elseif text == "off" or text == "aus"
+ or text == "-" or text == "0" then
+ set_status(false)
+ elseif text == "?" or text == "status"
+ or text == "." or text == "#"
+ or text == "#" or text == "" then
+ get_status(true)
+ else
+ minetest.display_chat_message(".colourchat_status +|-|1|0..\n")
+ end
+ return true
+ end,
+})
+
+
minetest.display_chat_message( "[CSM colour_chat] loaded")