-
Notifications
You must be signed in to change notification settings - Fork 2
Quick Start
This page describes how to 'install' CommandblocksJS, write your first script, and write it to a world.
##Downloading & installing CommandblocksJS
- Download the newest release from https://github.com/M4GV5/CommandBlocksJS/releases
- Unpack the downloaded zip file
##Writing your first Script
CommandblocksJS can load any file as a script, so the easiest way is left click somewhere >New >Text document
and open the created file with the editor you prefer. Now let's say we want to write an auto announcer for our quick start. The first step is to create a function that announces the message whenever it is called:
function announce()
{
say("View the source at https://github.com/M4GV5/CommandBlocksJS/ !");
}
In this case we use say what is the same as command('say <text>');
We could also use tellraw('@a', '<text>');
what would be the same as command('tellraw @a {text:"<text>"}');
Now we need a timer that calls the announce function lets say every 2 minutes
timer(1200, announce);
- the first argument specifies the the time between timer ticks in this case 1200 (in deciseconds = 120sec)
- the second argument is the function called every timer tick
Note In JavaScript you can give an anonymous function as a parameter so the complete code would look like this:
timer(1200, function() {
say("View the source at https://github.com/M4GV5/CommandBlocksJS/tree/master/CommandBlocksJS !");
});
##Writing the commandblocks to a world So now that we have our script we need to write the commandblocks to our world. To do this:
- Open a terminal/console (
Windows+R>cmd>enter
on windows) - Navigate to the CommandblocksJS path:
cd C:\Path\To\CommandblocksJS
- Run CommandblocksJS.exe e.g.
CommandblocksJS.exe -s myscript.js -w ./myworld -x 1 -y 4 -z 14
CommandblocksJS requires 5 arguments: The script file -s
, the World Directory -w
and the location in the world where to build the commandblocks -x
, -y
and -z
. For more information see Howto and Parameter
Thats it! Now copy the world to your minecraft saves directory and launch minecraft The output should look like this:
Note there are three lines of commandblocks:
- The first one is your main function that sets up and calls the timer (third) function
- The second is the announce function that announces the message
- The third one is the timer function. The timer function calls itself every 10*0.1 second counts to 120 and when 120 is reached it calls the announce (second) function
In order to start your script you need to run the first function. So just press the button CommandblocksJS added for you ;)
##Got interrested? Read Compiletime vs Runtime for more Information of how it works
Or dive straight into the Documentation: Home