This command would allow you to process data in javascript (possibly node js, but that is too much to ask for) then return a command that the game will run.
This is how i imagined it:
In the datapack:
data/namespace/scripts/...
here would be the scripts,
and also a scripts.json file so the game would know which functions to run.
And the actual command itself would be:
script <namespace:script_id> [<parameter>, <parameter> ...]
You could stack as many parameters next to each other as you want. The parameters would be data that you provide javascript (like score/nbt data/block/entity), but for simplicity we will have one type in the example:
value <value>
Here is a detailed example:
The scripts.json inside data/foo/scripts would be:
{
"values": [
{
"path": "test.js",
"function_name": "flower",
"id": "give_me_a_flower"
}
]
}
Inside the values array are all the declarations of the functions. "path" is the path of the file. "function_name" is the functions name inside test.js. "id" is the script id: what we call inside the game.
And test.js would be:
function flower(number, number2) {
return [
"give @s minecraft:dandelion " + number,
"give @s minecraft:poppy " + number2
];
}
You can see we return an array of strings which are runned as commands inside the game. They will run in order as well.
Now, we go back into the game and type:
/script foo:give_me_a_flower value 17 value 3
We get 17 dandelions and 3 poppies.
Please upvote if you would like this idea to be implemented! <3
Please sign in to leave a comment.
1 Comments