diff --git a/evennia/settings_default.py b/evennia/settings_default.py index bab7619e43..646cb8b641 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -388,7 +388,9 @@ INLINEFUNC_ENABLED = False # Only functions defined globally (and not starting with '_') in # these modules will be considered valid inlinefuncs. The list # is loaded from left-to-right, same-named functions will overload -INLINEFUNC_MODULES = ["evennia.utils.inlinefunc", "server.conf.inlinefunc"] +INLINEFUNC_MODULES = ["evennia.utils.inlinefunc", + "evennia.utils.nested_inlinefuncs", + "server.conf.inlinefunc"] ###################################################################### # Default Player setup and access diff --git a/evennia/utils/nested_inlinefuncs.py b/evennia/utils/nested_inlinefuncs.py index 3ba3ec53b6..7708525cde 100644 --- a/evennia/utils/nested_inlinefuncs.py +++ b/evennia/utils/nested_inlinefuncs.py @@ -69,7 +69,7 @@ from evennia.utils import utils def pad(*args, **kwargs): """ - Pad to width. pad(text, width, align, fillchar) + Pad to width. $pad{text, width, align, fillchar} """ text, width, align, fillchar = "", 78, 'c', ' ' @@ -85,12 +85,12 @@ def pad(*args, **kwargs): return utils.pad(text, width=width, align=align, fillchar=fillchar) -def crop(text, *args, **kwargs): +def crop(*args, **kwargs): """ - Crop to width. crop(text, width=78, suffix='[...]') + Crop to width. $crop{text, width=78, suffix='[...]'} """ - text = width, suffix = "", 78, "[...]" + text, width, suffix = "", 78, "[...]" nargs = len(args) if nargs > 0: text = args[0] @@ -101,6 +101,20 @@ def crop(text, *args, **kwargs): return utils.crop(text, width=width, suffix=suffix) +def clr(*args, **kwargs): + """ + Colorize text. $crop{clr, text} + + """ + clr, text = "|n", "" + nargs = len(args) + if nargs > 0: + clr = args[0] + if nargs > 1: + text = args[1] + return "|" + clr.lstrip("|") + text + "|n" + + # we specify a default nomatch function to use if no matching func was # found. This will be overloaded by any nomatch function defined in # the imported modules.