diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/common/misc_helpers.lua | 32 | ||||
-rw-r--r-- | builtin/game/misc.lua | 31 |
2 files changed, 32 insertions, 31 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 70b23600a..e145a5bfc 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -638,3 +638,35 @@ if INIT == "client" or INIT == "mainmenu" then return core.formspec_escape(fgettext_ne(text, ...)) end end + +-- Client-sided mods don't have access to getbool +if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then + + function core.get_color_escape_sequence(color) + return "" + end + + function core.get_background_escape_sequence(color) + return "" + end + + function core.colorize(color, message) + return message + end + +else + + local ESCAPE_CHAR = string.char(0x1b) + function core.get_color_escape_sequence(color) + return ESCAPE_CHAR .. "(c@" .. color .. ")" + end + + function core.get_background_escape_sequence(color) + return ESCAPE_CHAR .. "(b@" .. color .. ")" + end + + function core.colorize(color, message) + return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") + end + +end diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 25376c180..618d4d97f 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -170,37 +170,6 @@ function core.http_add_fetch(httpenv) return httpenv end -if minetest.setting_getbool("disable_escape_sequences") then - - function core.get_color_escape_sequence(color) - return "" - end - - function core.get_background_escape_sequence(color) - return "" - end - - function core.colorize(color, message) - return message - end - -else - - local ESCAPE_CHAR = string.char(0x1b) - function core.get_color_escape_sequence(color) - return ESCAPE_CHAR .. "(c@" .. color .. ")" - end - - function core.get_background_escape_sequence(color) - return ESCAPE_CHAR .. "(b@" .. color .. ")" - end - - function core.colorize(color, message) - return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") - end - -end - function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end |