diff options
author | red-001 <red-001@outlook.ie> | 2017-03-17 18:20:13 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-03-17 19:20:13 +0100 |
commit | d31750cb9375a961bf225ede210435751edfe7c9 (patch) | |
tree | 24f156b57f3c1a905b0422275fe99487b4fce146 /builtin | |
parent | 7b74f04a611ddaf36d79c0c9ebbf7f2b89c12a64 (diff) | |
download | minetest-d31750cb9375a961bf225ede210435751edfe7c9.tar.gz minetest-d31750cb9375a961bf225ede210435751edfe7c9.tar.bz2 minetest-d31750cb9375a961bf225ede210435751edfe7c9.zip |
Give CSM access to use `core.colorize()` (#5113)
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 |