MysteryBlokHed / databind

Expand the functionality of Minecraft Datapacks.
https://databind.rtfd.io/en/stable
GNU General Public License v3.0
4 stars 0 forks source link

Text replacement in preprocessor #8

Closed MysteryBlokHed closed 3 years ago

MysteryBlokHed commented 3 years ago

Support for text replacement in a similar manner to C language #define's would be nice to have for repetitive commands or portions of commands. For example, if you frequently use a command like execute as @a[scores={example_obj=1..},nbt= etc., then you could define a replacement and reuse that instead. In addition to making long lines shorter, it would also make it easier to change one part of the command. Instead of trying to change it everywhere, making it possible to accidentally miss a line and create a bug, you only have to change one line at the top of your file.

The syntax could look something like this:

:def LONG_EXECUTE execute as @a[scores={custom_item_obj=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{custom_item:1b}}}] at @s

:func custom_item_stuff
LONG_EXECUTE run summon minecraft:lightning_bolt
:endfunc

The code for while loops is already effectively a preprocessor, so that code could be reused or reformatted to include finding text replacement definitions.

MysteryBlokHed commented 3 years ago

Definitions should be placed at the top of the file or they will be ignored