12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- local path = minetest.get_modpath("hivemind")
- --set namespace for hivemind functions
- hivemind = {}
- --------------
- ---hivemind Copyright 2020 Francisco "FreeLikeGNU" Athens
- --------------
- hivemind.version = "20200528"
- --https://notabug.org/freelikegnu/hivemind
- -- Strips any kind of escape codes (translation, colors) from a string
- -- https://github.com/minetest/minetest/blob/53dd7819277c53954d1298dfffa5287c306db8d0/src/util/string.cpp#L777
- function hivemind.strip_escapes(input)
- local s = function(idx) return input:sub(idx, idx) end
- local out = ""
- local i = 1
- while i <= #input do
- if s(i) == "\027" then -- escape sequence
- i = i + 1
- if s(i) == "(" then -- enclosed
- i = i + 1
- while i <= #input and s(i) ~= ")" do
- if s(i) == "\\" then
- i = i + 2
- else
- i = i + 1
- end
- end
- end
- else
- out = out .. s(i)
- end
- i = i + 1
- end
- --print(("%q -> %q"):format(input, out))
- return out
- end
- local function strip_escapes(input)
- hivemind.strip_escapes(input)
- end
- local function print_s(input)
- print(hivemind.strip_escapes(input))
- end
- local S = minetest.get_translator("hivemind")
- local hivemind_version = hivemind.version
- minetest.log("action", "the [MOD] hivemind " ..hivemind_version.. " is awakened....")
- print_s(S("Please report issues at https://notabug.org/freelikegnu/hivemind/issues "))
- print_s(S(" The heart of hivemind beats with the rhythm of encounters, the mind is shared among entities."))
- dofile(path .. "/hivemind.lua")
|