User Tools

Site Tools


definitions

FileFormat::Definitions

The Definitions format is used for defining many things in Chunk Stories, including voxels, materials, items and so on. These files all use the .def file extension, but depending on where the file is located, only some sorts of definitions will be read from it.

Such files are read and wrapped into subclasses of the Definition class, and expose the following methods:

public String getName();

/** Resolves a property from the arguments defined in the .items file. May apply some macros ! */
public String resolveProperty(String propertyName);

/** Do the same as above but provides a default fallback value instead of null */
public String resolveProperty(String propertyName, String defaultValue);

public List<String> getAllProperties();

Syntax

You begin a definition by stating the kind of thing you are defining, ie an item, a voxel type, an entity type and so on ( Read the specific wiki pages for all the definables ). You then state the name of the defined thing, then inside curly brackets you may specify any number of properties.

item example {
	noSpaces: noQuotesNeeded
	memes: "nice doggo [0.0-2016.0]"
	bidon: "<name> giving [1-5] keks looking at <memes>"
}

item fancierExample {
	compoundProperty {
		howNice: "is it"
		answer: "better than json5"
	}
}

A new addition in later revisions of the API is the ability to have “compound” properties. These are merely syntactic sugar and keep things very simple, as a compound property just exposes what it contains as a normal property, with the compound property name and a dot appended at the start, ie you can call compoundProperty.howNice

Macros

The <name> tag corresponds to the name of current properties block. Alternatively, ~ can be used.

The <…> tag in general can be used to reference any other property in this properties block.

The [1-5] tag will return a random integer value in the range [1-5], both included

The [0.0-2016.0] tag will return a random float value in the range [0.0-2016.0], both included

ANTLR Grammar

TODO: Once implemented, link to the g4 files on GitHub

definitions.txt · Last modified: 2018/09/10 12:12 by gobrosse