0

Explain importing for filter functions

This code is correct, but doesn't work correctly with signs since they got JSON text formats in 14w25a. I will try to create another PR with an improved sign function tomorrow, but it's turning out to be complex, so for the moment, I'll stick with this tip on making imports work.
This commit is contained in:
tdierks
2015-02-11 00:41:51 -05:00
parent d696df2a1f
commit fc150a7739

View File

@@ -55,6 +55,15 @@ be used as the hover text, the second will be used as the info window content::
if poi['id'] == "Chest":
return ("Chest", "Chest with %d items" % len(poi['Items']))
Because of the way the config file is loaded, if you need to import a function or module
for use in your filter function, you need to explicitly load it into the global namespace:
global escape
from cgi import escape
def signFilter(poi):
if poi['id'] == 'Sign':
return "\n".join(map(escape, [poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']]))
Since writing these filters can be a little tedious, a set of predefined filters
functions are provided. See the :ref:`predefined_filter_functions` section for
details.