• Hey! Register here to create your account, engage with the community, and talk about what is new!

Programming How to read my text translations of DF code

HackerDragon9999

Forum adept
Joined
Jan 18, 2023
Messages
112
Reaction score
19
Part I: Blocks
Player Events, Entity Events, Functions, and Proccesses (so the ones that start code lines) are written like this:
Event Name (Parameters) #Tags >
If Player, If Entity, If Game, If Variable, and Repeat blocks are written like this:
Event Name (Parameters) #Tags {
-- Stuff inside the pistons/brackets
}

Else blocks are written like this (replacing the end of an If block)
} else {
-- Stuff inside the pistons/brackets
}

Everything else is written like this:
Event Name (Parameters) #Tags
Part II: Values
Texts: "hello world"
Numbers: 69
Locations: (10, 20, 30)
Vectors: <1, 2, 3>
Sounds: ~Zombie Ambient, 1.0, 2.0~
Particles: *Dust, ff0000, 0%, 1.0, 0%* (paramaters in the order on the particle item)
Potions: Speed C (1:09)
Variables: %default susLevel -s
Game Values: [Event Block Location]

And that's it!
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,254
Reaction score
351
what about the potion amplifier? is the is the character? (like C is speed 3?)
 

HellishBro

Active member
Joined
Nov 11, 2022
Messages
45
Reaction score
3
hmmm
lemme try smth
very untested code

```antlr
grammar DF;
prog: header* EOF;

header: category=NAME action=NAME params tags? '>' stmt* '<';
stmt: regstmt | blockstmt;
regstmt: category=NAME action=NAME params tags?
blockstmt: category=NAME action=NAME params tags? '{' stmt* '}';

params: '(' (value (',' value)*)? ')';
tags: '#' STRING;

value: text | number | loc | vec | snd | part | pot | var | gval;
text: STRING;
number: NUMBER;
loc: '(' x=NUMBER ',' y=NUMBER ',' z=NUMBER (',' pitch=NUMBER ',' yaw=NUMBER)? ')';
vec: '<' x=NUMBER ',' y=NUMBER ',' z=NUMBER '>';
snd: '~' STRING ',' pitch=NUMBER ',' vol=NUMBER '~';
part: '*' STRING (',' (STRING | NUMBER | PERCENT | HEX))* '*';
pot: STRING NUMBER '(' NUMBER ':' NUMBER ')';
var: NAME;
gval: '[' NAME+? ']';
```

and then you write your own token rules
 
Top Bottom