Entity Filtering
General description
Enity filtering is a server functionality that allows you to filter entities you can specify those with all fancy kind of queries. It does have a simple python interface. Entity filter in its core simply tells you whether a given entity matches the given criteria.
Usage
The tool is suppose to help world creators in writing scripts. To start working simply add:
from entity_filter import *
It currently has one method, get_filter which accepts a query string and return a PyFilter object (Defined in Py_Filter.h/cpp). Filter object has .match_entity method which accepts an entity and returns true\false whether it matches the query.
Query string examples
- "entity.type='bear'" - gives you filter that filters bears :D
- "entity.type='bear'|'rabbit' and entity.mass > 25 - gives your filter that selectes bears or rabbits which have mass greater than 25
Example of python usage would be
# module include section from entity_filter import * # some code here filter = get_filter("entity.type=\'bear\'")
You can use numbers, true\false without quotations.
PyMap Extension
Entity filtering also added one new method for Memory map class. That is:
find_by_filter
Function accepts a filter as arguement and returns a list of all entities in given entity's memory that match the criteria.
Architecture
Entity_filter module is added in C++ code (Python_API.cpp:596)