internal rules - mt-sane/lsystem GitHub Wiki

LSysten has a small set of internal rules. They are included to provide functionality that would not be possible with normal rule mechanics.

Parameters

Axioms can contain parameters. Parameters are enclosed in parenthesis and get prefixed to the rule keys. Paramters can contain open brackets '('. Closing brackets ')' have to be escaped with a backslash '' character. Note that in Lua backslash is also a escape character that has to be escaped with itself. So you actually need two backslashes to get one into the string.

Parameters are consumed by rules. This means that the parameters will not be copied to the next generation's axiom. If a rule needs to keep it's parameter prefix the rule's axiom with a point '.' character. The '.' will be replaced with the parameters to the rule.

Examples

local testAxiom = "xxx see below xxx"

local sys = LSystem.New(testAxiom, { diag = "action"} )
sys.rules.A = LSystem.Rule.New("A(cat)")
sys.rules.B = LSystem.Rule.New(".B")
sys:Build()
minetest.log("action", "Result axion="..table.concat(sys.axiom))
testAxiom key parameter resulting axiom
(dog)A A 'dog' A(cat)
A(dog)A A nil
A 'dog' A(cat)A(cat)
((dog\))AB A '(dog)'
B nil A(cat)B

Stack

LSystem has an internal stack. It is used to store a local state and can be accessed with the internal push '[' an pop ']' rules.

Push

Stores the local state on the stack.

Pop

Restores the local state from the stack.

Examples

todo

⚠️ **GitHub.com Fallback** ⚠️