Repository navigation
Syntax Basics
- Blocks and Indentation
- Comments
- Inheritance
- Realms
- Attach (ECS)
- Const
- References & Interpolation
- Native Types
- Include
YTL uses indentation (like Python or YAML) to define structure. There are no curly braces for blocks, only for inheritance and arrays.
A block is defined by a name followed by a colon :. Everything indented below it belongs to that block.
Server:
host "localhost"
port 8080YTL supports three types of comments.
// Single line comment
# Hash comment (useful for configs)
/*
Multi-line block comment
*/Use curly braces {} to inherit from one or more blocks.
Character:
health 100
Warrior{Character}:
damage 10You can inherit from multiple parents: MyApp{Network, Database}:
Instead of duplicating code for different difficulties or environments, use Realm.
Warrior:
health 100
Realm "Hardcore":
health 50 // Overrides only in Hardcore modeBring Entity-Component-System architecture to your configs. Inject traits directly into entities.
Goblin:
health 50
Attach ytl://components/poison.ytlProtect critical fields from being overwritten in child blocks.
Server:
Const port 8080
Realm "prod":
// port 443 <-- This will throw an LSP error!Use * to reference other values or interpolate strings.
Network:
ip 192.168.1.1
port 8080
Server:
gateway *ip
// Note Interpolation requires quotes, because '*' is not part of a valid URL
url "http://*ip:*port" YTL understands complex data types out of the box.
Weapon:
damage 13~30 // Random range
crit_chance 25% // PercentageSpawn:
position (10, 5, 2)
color (255, 0, 0, 255)Server:
ip 192.168.1.1
mac 00:1A:2B:3C:4D:5E
subnet 192.168.1.0/24Service:
id 550e8400-e29b-41d4-a716-446655440000
version 1.2.3Load values from the system environment. You can also provide a default value using :-.
Database:
host $DB_HOST
port $DB_PORT:-5432 // Uses 5432 if $DB_PORT is not setSystem:
linux_path /usr/local/bin
windows_path C:\Windows\System32Globally import root blocks from another file.
Include ytl://base_network.ytl