0

Merge branch 'master' of git://github.com/overviewer/Minecraft-Overviewer into JSObserver

This commit is contained in:
Thomas Lake
2012-05-25 14:00:16 +01:00
29 changed files with 820 additions and 120 deletions

View File

@@ -70,7 +70,7 @@ A more complicated example
renders["survivalnight"] = {
"world": "survival",
"title": "Survival Daytime",
"title": "Survival Nighttime",
"rendermode": smooth_night,
"dimension": "overworld",
}
@@ -115,6 +115,57 @@ individual renders to apply to just those renders.
See the ``sample_config.py`` file included in the repository for another
example.
A dynamic config file
=====================
It might be handy to dynamically retrieve parameters. For instance, if you
periodically render your last map backup which is located in a timestamped
directory, it is not convenient to edit the config file each time to fit the
new directory name.
Using environment variables, you can easily retrieve a parameter which has
been set by, for instance, your map backup script. In this example, Overviewer
is called from a *bash* script, but it can be done from other shell scripts
and languages.
::
#!/bin/bash
## Add these lines to your bash script
# Setting up an environment variable that child processes will inherit.
# In this example, the map's path is not static and depends on the
# previously set $timestamp var.
MYWORLD_DIR=/path/to/map/backup/$timestamp/YourWorld
export MYWORLD_DIR
# Running the Overviewer
overviewer.py --config=/path/to/yourConfig.py
.. note::
The environment variable will only be local to the process and its child
processes. The Overviewer, when run by the script, will be able to access
the variable since it becomes a child process.
::
## A config file example
# Importing the os python module
import os
# Retrieving the environment variable set up by the bash script
worlds["My world"] = os.environ['MYWORLD_DIR']
renders["normalrender"] = {
"world": "My world",
"title": "Normal Render of My World",
}
outputdir = "/home/username/mcmap"
Config File Specifications
==========================
@@ -389,6 +440,20 @@ values. The valid configuration keys are listed below.
**Default:** ``95``
``optimizeimg``
This option specifies which additional tools overviewer should use to
optimize the filesize of png tiles.
The tools used must be placed somewhere, where overviewer can find them, for
example the "PATH" environment variable or a directory like /usr/bin.
This should be an integer between 0 and 3.
* ``1 - Use pngcrush``
* ``2 - Use advdef``
* ``3 - Use pngcrush and advdef (Not recommended)``
Using this option may significantly increase render time, but will make
the resulting tiles smaller, with lossless image quality.
**Default:** ``0``
``bgcolor``
This is the background color to be displayed behind the map. Its value
should be either a string in the standard HTML color syntax or a 4-tuple in
@@ -396,11 +461,12 @@ values. The valid configuration keys are listed below.
**Default:** ``#1a1a1a``
.. _option_texture_pack:
.. _option_texturepath:
``texturepath``
This is a where a specific texture pack can be found to be used during this render.
It can be either a folder or a directory. Its value should be a string.
It can be either a folder or a zip file containing the texture pack.
Its value should be a string.
.. _crop:
@@ -509,6 +575,18 @@ values. The valid configuration keys are listed below.
**Default:** ``[]`` (an empty list)
.. _option_overlay:
``overlay``
This specifies which renders that this render will be displayed on top of.
It should be a list of renders.
.. warning::
At this time, this feature is not fully implemented.
**Default:** ``[]`` (an empty list)
``showspawn``
This is a boolean, and defaults to ``True``. If set to ``False``, then the spawn
icon will not be displayed on the rendered map.
@@ -593,6 +671,15 @@ Cave
only_lit
Only render lit caves. Default: False
Hide
Hide blocks based on blockid. Blocks hidden in this way will be
treated exactly the same as air.
**Options**
minerals
A list of block ids, or (blockid, data) tuples to hide.
DepthTinting
Tint blocks a color according to their depth (height) from bedrock. Useful
mainly for cave renders.
@@ -672,7 +759,7 @@ are referencing the previously defined list, not one of the built-in
rendermodes.
Built-in Rendermodes
--------------------
====================
The built-in rendermodes are nothing but pre-defined lists of rendermode
primitives for your convenience. Here are their definitions::

View File

@@ -17,7 +17,7 @@ So let's get started!
.. note::
This page is still under construction
This page is continually under construction
.. contents::
@@ -82,7 +82,7 @@ pre-rendered sprite (a small image). The basic idea is to iterate over the
blocks of the world and draw these sprites to the appropriate location on the
map.
These are the high-level tasks The Overviewer must preform in rendering a map:
These are the high-level tasks The Overviewer must perform in rendering a map:
1. Render each block sprite from the textures
2. Scan the chunks of the world and determine which tiles need rendering
@@ -143,7 +143,7 @@ transformations can be chained together simply by multiplying the transformation
matrices together, only one transformation is actually done.
This can be seen in the function
:func:`overviewer_core.textures.transform_image`. It preforms three steps:
:func:`overviewer_core.textures.transform_image`. It performs three steps:
1. The texture is re-sized to 17 by 17 pixels. This is done because the diagonal
of a square with sides 17 is approximately 24, which is the target size for

View File

@@ -246,7 +246,7 @@ If you want or need to provide your own textures, you have several options:
overviewer.exe.
* Specify any terrain.png or texture pack you want with the
:ref:`texture_pack<option_texture_pack>` option.
:ref:`texturepath<option_texturepath>` option.
If you copy your world before you render it
-------------------------------------------

View File

@@ -20,51 +20,97 @@ Filter Functions
----------------
A filter function is a python function that is used to figure out if a given POI
should be part of a markerSet of not. The function should accept one argument
(a dictionary, also know as an associative array), and return a boolean::
should be part of a markerSet of not, and to control how it is displayed.
The function should accept one argument (a dictionary, also know as an associative
array), and return a string representing the text to be displayed. For example::
def signFilter(poi):
"All signs"
return poi['id'] == 'Sign'
if poi['id'] == 'Sign':
return "\n".join([poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']])
If a POI doesn't match, the filter can return None (which is the default if a python
functions runs off the end without an explicit 'return').
The single argument will either a TileEntity, or an Entity taken directly from
the chunk file. In this example, this function returns true only if the type
of entity is a sign. For more information of TileEntities and Entities, see
the chunk file. It could also be a special entity representing a player's location
or a player's spawn. See below for more details.
In this example, this function returns all 4 lines from the sign
if the entity is a sign.
For more information of TileEntities and Entities, see
the `Chunk Format <http://www.minecraftwiki.net/wiki/Chunk_format>`_ page on
the Minecraft Wiki.
.. note::
The doc string ("All signs" in this example) is important. It is the label
that appears in your rendered map
A more complicated filter function can construct a more customized display text::
A more advanced filter may also look at other entity fields, such as the sign text::
def chestFilter(poi):
if poi['id'] == "Chest":
return "Chest with %d items" % len(poi['Items'])
def goldFilter(poi):
"Gold"
return poi['id'] == 'Sign' and (\
'gold' in poi['Text1'] or
'gold' in poi['Text2'])
This looks for the word 'gold' in either the first or second line of the signtext.
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.
Special POIs
------------
There are currently two special types of POIs. They each have a special id:
PlayerSpawn
Used to indicate the spawn location of a player. The player's name is set
in the ``EntityId`` key, and the location is in the x,y,z keys
Player
Used to indicate the last known location of a player. The player's name is set
in the ``EntityId`` key, and the location is in the x,y,z keys.
.. note::
The player location is taken from level.dat (in the case of a single-player world)
or the player.dat files (in the case of a multi-player server). The locations are
only written to these files when the world is saved, so this won't give you real-time
player location information.
Here's an example that displays icons for each player::
def playerIcons(poi):
if poi['id'] == 'Player':
poi['icon'] = "http://overviewer.org/avatar/%s" % poi['EntityId']
return "Last known location for %s" % poi['EntityId']
Note how each POI can get a different icon by setting ``poi['icon']``
Render Dictionary Key
---------------------
Each render can specify a list of zero or more filter functions. Each of these
filter functions become a selectable item in the 'Signs' drop-down menu in the
rendered map. For example::
rendered map. Previously, this used to be a list of functions. Now it is a list
of dictionaries. For example::
renders['myrender'] = {
'world': 'myworld',
'title': "Example",
'markers': [allFilter, anotherFilter],
'markers': [dict(name="All signs", filterFunction=signFilter),
dict(name="Chests", filterFunction=chestFilter, icon="chest.png")]
}
The following keys are accepted in the marker dictionary:
``name``
This is the text that is displayed in the 'Signs' dropdown.
``filterFunction``
This is the filter function. It must accept at least 1 argument (the POI to filter),
and it must return either None or a string.
``icon``
Optional. Specifies the icon to use for POIs in this group. If omitted, it defaults
to a signpost icon. Note that each POI can have different icon by setting the key 'icon'
on the POI itself (this can be done by modifying the POI in the filter function. See the
example above)
Generating the POI Markers