Data Packs Tool

AMS Transpiler in Python - Readable MCFunction Files

  • 2.5k views 0 today
  • save_alt 40 downloads
Compatibility
Minecraft 1.13
to version
Minecraft 1.19
Changes include
  • Functions
  • 8
  • 3
  • 4
PixelRayn
Lvl 38Artisan System
15

Advanced Minecraft Scripting


This project aims at producing a more human readable version of Minecraft's mcfunction format. This documentation will explain the new syntax, the components of the compiler and contains a user guide to use this program to compile your project into a Minecraft datapack.

Please read the docs on GitHub.

The Language


The AMS transpiler does not actually introduce a new language, but offers a way of organizing existing minecraft code into a more readable format using indentation.
parent
line1

#comment
line2

will compile to
parent line1
#comment
parent line2

This can be useful when you need to write a number of similar lines. For example:


execute store result score @s
x1 run data get entity @s Pos[0] 1
y1 run data get entity @s Pos[1] 1
z1 run data get entity @s Pos[2] 1


Parsed through the compiler this is assembled into this valid mcfunction code.


execute store result score @s x1 run data get entity @s Pos[0] 1
execute store result score @s y1 run data get entity @s Pos[1] 1
execute store result score @s z1 run data get entity @s Pos[2] 1


If statements can also be dramatically simplified:


execute if
condition1 run
say Detected Condition 1
function namespace:condition1

condition2 run
say Detected Condition 2
function namespace:condition2



Installation


Python scripts don't necessarily need to be installed. This section will however explain how to set it up.

Setting up the Scripts


After installing python, download this repository either through the github website or using git through the console:
git clone https://github.com/davidkowalk/tabbed_minecraft_scripting.git

or if you don't have git:
wget https://github.com/davidkowalk/tabbed_minecraft_scripting/archive/master.zip -outfile advanced_minecraft_scripting.zip

Once you downloaded (and unpacked) the tool into a folder you would like to store it in you need to resolve the dependencies. This project is only dependent on kivy to generate the user interface. Type
pip install kivy

Install the script as an alias in the console


If you are on windows it's also recommended to run the install.ps1 or install.sh on linux, so you can use the ams-transpiler in the console.

Windows Powershell
PS> .\install.ps1

Searching for profile...
Updating start-up script...
Saving to Disk...

===========
|| DONE! ||
===========
PS >

Linux Bash
user: $ ./install.sh

Finding Executable Directory...
Adding alias to startup file...
Update Current Session
===========
|| DONE! ||
===========

Please note that the Windows script will check whether the script is already installed, the Linux script will not. The scripts set the python script as an alias. The install will break if you move the repository after running the script.

After you are done check the install in the console (PowerShell on Windows and the Terminal on Linux) by typing
> ams -h

ams transpiler is designed for mincraft mcfunctions to [...]



See the docs for usage reference.

More like this

  Have something to say?

Loumardes
09/29/2020 6:33 am
Level 22 : Expert System
Well done



I did not got the time to download it and test myself, but from what you show it seem well designed



May I suggest you to add support for function recursivity and loops ?

I have myself writed in the past a tool to create mcfunctions files

You can find it here https://github.com/Loumardes/BlocCode

in my case, the format was an actual python code with added fonctions



I don't remember if the github repository was up to date, and I definitely should improve the doc if I were to resume the project



Tell me if you want to discuss this on discord or elsewere, and keep up the good work :)
1
PixelRayn
10/04/2020 2:42 pm
Level 38 : Artisan System
While it sounds like a great idea, I think this is beyond the scope of this project. The ams transpiler does not currently add any features. It more or less just bunches strings together in a way that reduces the amount of work to be done.

I would suggest you write a ticket on github and maybe someone will branch it :)
1
TheVirusNVGM
09/23/2020 4:40 pm
Level 1 : New Miner
Fantastic!
1
Beatso
09/23/2020 4:06 pm
Level 68 : High Grandmaster Blueberry
w o w
2

Welcome