AMS Transpiler in Python - Readable MCFunction Files

  • check_circle Functions
                  avatar PixelRayn
                  Level 25 : Expert Engineer
                  10

                  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 github.com/davidkowalk/advanced_minecraft_scripting.git

                  or if you don't have git:
                  wget github.com/davidkowalk/advanced_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.
                  CompatibilityMinecraft 1.13
                  toMinecraft 1.17 Snapshot
                  Tags

                  1
                  09/29/2020 6:33 am
                  Level 19 : Journeyman Engineer
                  Loumardes
                  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
                  10/04/2020 2:42 pm
                  Level 25 : Expert Engineer
                  PixelRayn
                  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
                  09/23/2020 4:40 pm
                  Level 1 : New Miner
                  TheVirusNVGM
                  Fantastic!
                  2
                  09/23/2020 4:06 pm
                  Level 49 : Master Answer
                  Beatso
                  w o w
                  Planet Minecraft Logo

                  Website

                  © 2010 - 2020
                  www.planetminecraft.com

                  Welcome