📦Blocks

Each line is separated between blocks and coordinates in the "data" section inside a LevelZ File. This page will cover the basic implementation of blocks.

Blocks can be declared with any name, which will be passed to the parser. The "data" section is indicated after the three dashes (---) have been written.

---
stone: ...

Properties

Blocks can also provide attributes that will also be passed to the parser.

---
grass<snow=true>: ...
end
---
magma<temperature=2.5,>: ...
end

Attributes need to be separated by a comma.

Implementations that support type (e.g. Java, C++) will automatically determine attribute types. For example, true and false indicate booleans, as well as other types such as integers and doubles. Anything else is passed as a string.

After the "data" section has been finished, all files must be completed with the end keyword to indicate that the parser should stop.

Random Blocks

LevelZ File Formats natively support randomly selecting blocks to be placed. To declare this, you can combine different blocks into a list-like syntax with curly braces ({}):

{grass<snow=false>, dirt}: ...

By default, all blocks placed here will have the same chance. To tip the favor into a specific block, you can specify a chance out of 1.0.

{0.25=grass<snow=true>,0.75=grass<snow=false>}: ...

Implementations will not and should not enforce the chances of adding up to 1.0. By default, they should return a null-like block, or something that represents nothing.

Combining with Join (*) or Matrix (^)

When you combine the join or matrix operator with random blocks, each random pool will be rolled for each individual coordinate. This means that you can automatically spread out different kinds of blocks over an area, instead of it all being one type.

---
{grass, dirt}: [0, 0]*[0, 1]*(0, 0, 2, 2)^[0, 2]

Examples

Example 1

---
stone: ...
grass<snow=false>: ...
grass<snow=true>: ...

This level indicates that stone, grass, and snowy grass should be placed somewhere.

Example 2

---
magma<temperature=10.0>: ...
magma<temperature=20.0>: ...
stone<cracked=true>: ...

This level indicates that hot and very hot magma, along with not-hot stone should be placed somewhere else.

Example 3

---
{grass,dirt}: ...
{0.2=grass,0.8=dirt}: ...

This level indicates that a mix of grass and dirt should be, followed by a heavier mix of dirt and a lighter mix of grass to be placed somewhere.

To learn where to specify things that should be placed, go to the Coordinates section.

Last updated