0

Updated documentation

* Added paragraph and example about returning tuples from a filter
  (Issue #859)

* Added section about manualpois
  (Issue #858, Issue #869, Issue #598)

* Fixed a typo in the FAQ

* Added logging to file to the FAQ
  (Issue #871)
This commit is contained in:
Nicolas Frattaroli
2013-01-21 18:13:50 +01:00
parent a5ee1b68ba
commit ae5e146eff
2 changed files with 84 additions and 1 deletions

View File

@@ -47,6 +47,13 @@ A more complicated filter function can construct a more customized display text:
if poi['id'] == "Chest":
return "Chest with %d items" % len(poi['Items'])
It is also possible to return a tuple from the filter function to specify a hovertext
different from the text displayed in the info window. The first entry of the tuple will
be used as the hover text, the second will be used as the info window content::
def chestFilter(poi):
if poi['id'] == "Chest":
return ("Chest", "Chest with %d items" % len(poi['Items']))
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
@@ -81,6 +88,67 @@ Here's an example that displays icons for each player::
Note how each POI can get a different icon by setting ``poi['icon']``
Manual POIs
-----------
It is also possible to manually define markers. Each render can have a render dictionary key
called ``manualpois``, which is a list of dicts. Each dict represents a marker, and is required
to have at least the attributes ``x``, ``y``, ``z`` and ``id``, with the coordinates being Minecraft
world coordinates. (i.e. what you see in-game when you press F3)
An example which adds two POIs with the id "town", and then uses a filter function to filter for them::
def townFilter(poi):
if poi['id'] == 'Town':
return poi['name']
renders['myrender'] = {
'world':'myworld',
'title':'Example',
'manualpois':[
{'id':'Town',
'x':200,
'y':64,
'z':200,
'name':'Foo'},
{'id':'Town',
'x':-300,
'y':85,
'z':-234,
'name':'Bar'}],
'markers': [dict(name="Towns", filterFunction=townFilter, icon="town.png")],
}
Here is a more complex example where not every marker of a certain id has a certain key::
def townFilter(poi):
if poi['id'] == 'Town':
try:
return (poi['name'], poi['description'])
except KeyError:
return poi['name'] + '\n'
renders['myrender'] = {
'world':'myworld',
'title':'Example',
'manualpois':[
{'id':'Town',
'x':200,
'y':64,
'z':200,
'name':'Foo',
'description':'Best place to eat hamburgers'},
{'id':'Town',
'x':-300,
'y':85,
'z':-234,
'name':'Bar'}],
'markers': [dict(name="Towns", filterFunction=townFilter, icon="town.png")],
}
Render Dictionary Key
---------------------