Ruichka / mlog-sugar

Sugar for Mindustry Logic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mindustry Logic Sugar

This is mlog extension that adds syntactic sugar.
Script converts syntactic sugar into mlog code.
It adds 3 macrooperators: $, % and *.

How to use

If you want to just use it: You can access online converter at http://mlog-sugar.ruika.repl.co/
If you want to include it in your project: Include the convertSugar(text) function from convert.js file in your project.

Operators list

Replacement ($)

This operator gets replaced with the substitution.
Syntax: $tag
Example:

%a=duo1
control shoot $a @thisx @thisy true

Result:

control shoot duo1 @thisx @thisy true

Definition (%)

This operator replaces all $tag entries with value.
Syntax: %tag=value
Example:

%leader=foreshadow1
sensor shootx $leader @shootX
sensor shooty $leader @shootY
sensor shooting $leader @shooting

Result:

sensor shootx foreshadow1 @shootX
sensor shooty foreshadow1 @shootY
sensor shooting foreshadow1 @shooting

Label (*)

This operator replaces all $tag entries with number of line which this operator is placed on.
Syntax: *tag
Example:

*a sensor enabled switch1 @enabled
jump $a equal enabled true

Result:

sensor enabled switch1 @enabled
jump 0 equal enabled true

Warnings

Operators in this extension are highly sensitive. All operators must strictly follow the syntax, otherwise it might lead to errors.

✔️ Correct ❌ Incorrect
Definition operator (%) must always be on a separate line. %a=8
op sub result $a 10
%a=8 op sub result $a 10
Definition operator (%) must have no spaces near "=" sign. %a="Hello world!" %a = "Hello world!"
All tags must not have any spaces. %my_number=20
op div result $my_number 5
%my number=20
op div result $my number 5
Label operator (*) must always be at start of line. *label print "Hi!" print "Hi!" *label

About

Sugar for Mindustry Logic

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%