forked from TOGoS/TMCMG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EMBEDDING
40 lines (30 loc) · 1.7 KB
/
EMBEDDING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
This documents at a very high level some of the internals of TMCMG.
== Chunks ==
A ChunkData object holds information about a single terrain chunk.
This includes the chunk's x, y position in the world and an array
of all blocks and their extended attributes.
ChunkData objects are populated with data by ChunkMungers.
ChunkMungers usually depend on the chunk's x and y being set
before they can populate the terrain.
== Compiling a TNL Expression ==
Use TNLWorldGeneratorCompiler (a subclass of TNLCompiler whose instances
are pre-loaded with all world generator-related functions) to compile
an expression. The simplest way is to call
#compile( <expression source>, <name of source> )
where <name of source> is e.g. the filename or URL that the source was
loaded from or the name of a text area on a form that the user typed it
into.
== TNL Functions ==
The TNL compiler can take a script as a string and output a
compiled object. What that object is depends on what was
written in the script. e.g. layered-terrain(...) compiles to a
WorldGenerator object, but simplex() compiles to a TNLFunctionDaDaDa_Da
(the interface for vector functions that take 3 doubles as inputs
and return one as output). To make use of the result of compiling
a script your program must know how to handle the different types
of things that may be returned (which may include throwing an
exception if you can't do anything useful with it).
You can add new functions/macro types by implementing MacroType
(you may want to extend BaseMacroType to save yourself some work) and
register it with the compiler (e.g. in the compiler's constructor
or by adding it to a collection like WorldGeneratorMacros).