Default Rule Functions - mt-sane/lsystem GitHub Wiki
LSystem supplies as set of basic build functions that perform actions that are commonly needed. These functions are kept in the LSystem.Rule.B
namespace (table).
Logs diagnostic infos using minetest.log.
The l-system's build information for the rule.
The parameter has the following fields:
The key character that is assigned zu this rule.
The sytems global state.
The sytems local state.
This Field is optional.
The default functions use this field manage the current position.
This Field is optional.
The default functions use this field manage the current direction.
Other paramters passed to the rule
Fields used in the global state.
If nil the function does nothing. All other values will be passed as first parameter to minetest.log.
nil or a table of log levels per rule key. If nil all rules are logged with level 1.
Log levels:
No log output is generated.
Logs the rule's key and the parameters that it's build function is called with.
Default rules use LSystem.Rule.B.Diag
for action log.
Additionally log what the rule does. Default rules log when they change info fileds in the state. If they contain a random component the result will be logged too.
Additionally log whatever else is deemed necessary. Default rules do not log anything verbose.
If nil the default log level is 1. Other values set the log level for all rules that don not have an explicit log level.
Fields used in the local state.
Not used.
local sys = LSystem.New("A")
local sys = LSystem.New("A", { diag = "action", diagLevels = { default = 0, } } )
This will logg the current axiom. Infos for rule 'A' and basic action for rule 'B' all other rules don't get logged.
local sys = LSystem.New(
"A",
{ diag = "action",
diagLevels = { default = 0, A=2, B=1, },
}
)
This will logg the current axiom. Verbose for rule 'A', info for rule 'B', rule 'C' does not produce diagnostis. All other rules get logged on basic action level.
local sys = LSystem.New(
"A",
{ diag = "action",
diagLevels = { A=3, B=2, C=0, },
}
)
Moves the current position into the current direction.
The l-system's build information for the rule.
See Diag for details.
Fields used in the global state.
Not used.
Fields used in the local state.
The current position.
The function simply adds dir
to pos
.
The current direction.
Used to increment pos
.
With k being the rule key, and pos
at the center {x=0,y=0,z=0}
Current dir | axiom | resulting pos
|
---|---|---|
west | k |
{x=-1,y=0,z=0} |
west | kkk |
{x=-3,y=0,z=0} |
noth | k |
{x=0,y=0,z=1} |
up | kk |
{x=0,y=2,z=0} |
todo doc
The l-system's build information for the rule.
See Diag for details.
Fields used in the global state. todo
Fields used in the local state. todo
todo
Sets the current direction to a cardinal.
SetDir sets the dir
field in the local state.
The l-system's build information for the rule.
See Diag for details.
This parameter selects the cardinal.
If nil this function does nothing.
key | meaning | vector |
---|---|---|
n |
north | vector.new( 0, 0, 1) |
s |
south | vector.new( 0, 0,-1) |
e |
east | vector.new( 1, 0, 0) |
w |
west | vector.new(-1, 0, 0) |
u |
up | vector.new( 0, 1, 0) |
d |
down | vector.new( 0,-1, 0) |
c |
center | vector.new( 0, 0, 0) |
Fields used in the global state.
Not used.
Fields used in the local state.
The current position.
Will be set to the cardinal supplied in the parameter.
With k being the rule key.
axiom | dir | meaning |
---|---|---|
(w)k |
{x=-1,y=0,z=0} |
West |
(n)k |
{x=0,y=0,z=1} |
North |
(s)k |
{x=0,y=0,z=-1} |
South |
(u)k |
{x=0,y=1,z=0} |
Up |
Changes the current direction by 90°.
Turn changes the dir
field in the local state.
The parameter selects the turning direction.
Think of the turning direction as the movement keys in computer games.
w = pitch down, s = pitch up
a = yaw left, d = yaw right
q = roll left, e = roll right
Fields used in the global state. todo
Fields used in the local state. todo
With rule key = 'k'
current dir = north. ( info.state.dir = Lib.Cardinal.C.n
).
axiom | resulting dir |
---|---|
(a)k |
west - Lib.Cardinal.C.w - (-1, 0, 0)
|
(d)k |
down - Lib.Cardinal.C.d - (0, -1, 0)
|
(d)k(e)k |
west - Lib.Cardinal.C.w - (-1, 0, 0)
|