* You will need to have Java version 7 or later installed on your
machine. Check the version by typing `java -version` at a command
prompt.
* You will need to [install SpigotMC][spigot] on your
machine. SpigotMC is a customized version of Minecraft Server that
makes it easy to install plugins and customize Minecraft. You can
[download the SpigotMC server here.][spigotdl]
ScriptCraft is a Minecraft Server Mod which only works with Minecraft
for Personal computers (Windows, Mac and Linux). It does not work with
X-BOX, Playstation or WiiU versions of the game. You will need to have
Java version 7 or later installed. Check the version by typing `java
-version` at a command prompt.
# Installation
Before installing ScriptCraft you must first install SpigotMC which is a special version of Minecraft Server that makes it easy to customize the game.
Before installing ScriptCraft you must first install SpigotMC which is
a special version of Minecraft Server that makes it easy to customize
the game.
## Installing and Running SpigotMC
Follow these steps to download and install SpigotMC on your machine.
Follow these steps to download and install SpigotMC.
1. Download Spigot's [BuildTools.jar][spigotdl]
2. Save the BuildTools.jar file to a new directory called spigotmc.
@ -98,8 +98,13 @@ Follow these steps to download and install SpigotMC on your machine.
4. When the build is done, there will be a new file beginning with `spigot` and ending in `.jar` in the spigotmc directory. Run this file by typing `java -jar spigot-1.10.2.jar` (it might not be that exact name - you can list files in the directory by typing `dir` (Windows) or `ls` (Mac and Linux).
5. The server will start up then shut down very shortly afterwards. You'll need to edit a file called `eula.txt` - change `eula=false` to `eula=true` and save the file.
6. Run the `java -jar spigot-1.10.2.jar` command again - this time the server will start up. Shut it down by typing `stop` at the server prompt.
7. Download the [scriptcraft.jar][dl] plugin and save it to the `plugins` directory and restart the server by typing `java -jar spigot-1.10.2.jar`.
9. At the server prompt type `js 1 + 1` and hit enter. The result `2` should be displayed.
## Installing ScriptCraft
Follow these steps to download and install ScriptCraft.
1. Download the [scriptcraft.jar][dl] plugin and save it to the `plugins` directory and restart the server by typing `java -jar spigot-1.10.2.jar`.
2. At the server prompt type `js 1 + 1` and hit enter. The result `2` should be displayed.
Congratulations - you've just installed your Custom Minecraft Server and are ready to begin writing your first mod!
@ -116,7 +121,7 @@ username to the ops.txt file in your server directory.
Launch the server, then launch the Minecraft client and create a new
server connection. The IP address will be `localhost` . Once you've
connected to your server and have entered the game, look at a
ground-level block and type…
ground-level block and type:
/js up().box( blocks.wool.black, 4, 9, 1 )
@ -156,12 +161,12 @@ To get started writing your own mod, take a look at some of the
Because the SpigotMC API is open, all of the SpigotMC API is accessible
via javascript once the ScriptCraft plugin is loaded. There are a
couple of useful Java objects exposed via javascript in the
ScriptCraft plugin…
ScriptCraft plugin:
* `__plugin`– the ScriptCraft Plugin itself. This is a useful
starting point for accessing other SpigotMC objects. The `__plugin`
object is of type [org.bukkit.plugin.Plugin][api] and all
of its properties and methods are accessible. For example… `js
of its properties and methods are accessible. For example: `js
__plugin.name` returns the plugin's name
(JavaScript is more concise than the equivalent Java code:
`__plugin.getName()` ).
@ -192,7 +197,7 @@ If you would like to contribute source code and/or documentation changes please
ScriptCraft works with Bukkit Plugin and uses the Bukkit Configuration
API. On first loading, ScriptCraft will create a config.yml file in
the plugins/scriptcraft/ directory. This file looks like this…
the plugins/scriptcraft/ directory. This file looks like this:
extract-js:
plugins: true
@ -229,7 +234,7 @@ programs and how to do the same thing in JavaScript.
I highly recommend the series of [tutorials provided by CoderDojo Athenry][cda].
Developer Chris Cacciatore has created some interesting tools using ScriptCraft…
Developer Chris Cacciatore has created some interesting tools using ScriptCraft:
* [A wolf-bot][wb]
* [L-Systems (Large-scale fractal structures in Minecraft)][ls]
Follow these steps to download and install SpigotMC.
If you would like all admins to have scripting ability then issue the
following command:
1. Download Spigot's [BuildTools.jar][spigotdl]
2. Save the BuildTools.jar file to a new directory called spigotmc.
3. Open a terminal (Mac and Linux) or command prompt (windows) window and type `java -jar BuildTools.jar`. This will kick off a long series of commands to "build" SpigotMC.
4. When the build is done, there will be a new file beginning with `spigot` and ending in `.jar` in the spigotmc directory. Run this file by typing `java -jar spigot-1.10.2.jar` (it might not be that exact name - you can list files in the directory by typing `dir` (Windows) or `ls` (Mac and Linux).
5. The server will start up then shut down very shortly afterwards. You'll need to edit a file called `eula.txt` - change `eula=false` to `eula=true` and save the file.
6. Run the `java -jar spigot-1.10.2.jar` command again - this time the server will start up. Shut it down by typing `stop` at the server prompt.
You may be wondering how to change other aspects of the Minecraft game - pretty much all
aspects of the game can be changed. Changes are made using what are
called `API` calls - these are calls to functions and methods in
Minecraft - you can read more about these on the [CanaryMod API
Reference][cmapi].
Minecraft - you can read more about these on the [SpigotMC API
Reference][spigotapi].
## ...and Again, and Again, and Again,...
@ -943,8 +899,10 @@ var utils = require('utils');
var players = utils.players();
var sounds = require('sounds');
utils.foreach( players, function( player ) {
sounds.catMeow( player ); // canarymod
sounds.entityCatAmbient( player ); // spigot 1.9
/* canarymod only
sounds.catMeow( player );
*/
} );
```
@ -1066,7 +1024,7 @@ This time no message should appear on your screen.
The `if` statement tests to see if something is `true` or `false` and
if `true` then the block of code between the curly braces ( `{` and
`}` ) is executed - but only if the condition is true. The condition
in the above example is `!self.onGround` (self is not on ground) which
in the above example is `!self.onGround` (self is _not_ on ground) which
will be `true` if you are currently flying or `false` if you aren't.
What if you wanted to display a message only if a condition is *not*
@ -1122,29 +1080,29 @@ following code sends a message to any player who breaks a block in the
game...
```javascript
function myBlockDestroyHook( event ){
function myBlockBreakHook( event ){
var breaker = event.player;
echo( breaker, 'You broke a block');
}
events.blockDestroy( myBlockDestroyHook );
events.blockBreak( myBlockBreakHook );
```
The `events.blockDestroy()` function is just one of the many `events` functions which can be used to *register* a function to be called whenever a particular type of event occurs. In the
above code the blockDestroy function takes as a parameter a function
The `events.blockBreak()` function is just one of the many `events` functions which can be used to *register* a function to be called whenever a particular type of event occurs. In the
above code the blockBreak function takes as a parameter a function
I want to be called when that event occurs. The function I want called
in turn takes 1 parameter. The `event` object has all the information
about the event which just occurred. I can tell who broke the block
and send a message to the player. The important thing to note is that
the `myBlockDestroyHook` function defined above will not be called until a player breaks a
the `myBlockBreakHook` function defined above will not be called until a player breaks a
block. Try it - save the above code in a new file in the
`scriptcraft/plugins` directory then type `/js refresh()` to reload
scriptcraft. Then break a block in the game and you should see the
message 'You broke a block'.
There are many types of events you can listen for in Minecraft. You can
browse [all possible event registration functions][cmevts2] in the API Reference.
browse [all possible event registration functions][spevts2] in the API Reference.
For custom events (events which aren't in the net.canarymod.hook tree)
For custom events (events which aren't in the org.bukkit.event tree)
just specify the fully qualified class name instead. E.g. ...
Follow these steps to download and install SpigotMC.
If you would like all admins to have scripting ability then issue the
following command:
1. Download Spigot's [BuildTools.jar][spigotdl]
2. Save the BuildTools.jar file to a new directory called spigotmc.
3. Open a terminal (Mac and Linux) or command prompt (windows) window and type `java -jar BuildTools.jar`. This will kick off a long series of commands to "build" SpigotMC.
4. When the build is done, there will be a new file beginning with `spigot` and ending in `.jar` in the spigotmc directory. Run this file by typing `java -jar spigot-1.10.2.jar` (it might not be that exact name - you can list files in the directory by typing `dir` (Windows) or `ls` (Mac and Linux).
5. The server will start up then shut down very shortly afterwards. You'll need to edit a file called `eula.txt` - change `eula=false` to `eula=true` and save the file.
6. Run the `java -jar spigot-1.10.2.jar` command again - this time the server will start up. Shut it down by typing `stop` at the server prompt.
You may be wondering how to change other aspects of the Minecraft game - pretty much all
aspects of the game can be changed. Changes are made using what are
called `API` calls - these are calls to functions and methods in
Minecraft - you can read more about these on the [CanaryMod API
Reference][cmapi].
Minecraft - you can read more about these on the [SpigotMC API
Reference][spigotapi].
## ...and Again, and Again, and Again,...
@ -898,8 +854,10 @@ var utils = require('utils');
var players = utils.players();
var sounds = require('sounds');
utils.foreach( players, function( player ) {
sounds.catMeow( player ); // canarymod
sounds.entityCatAmbient( player ); // spigot 1.9
/* canarymod only
sounds.catMeow( player );
*/
} );
```
@ -1021,7 +979,7 @@ This time no message should appear on your screen.
The `if` statement tests to see if something is `true` or `false` and
if `true` then the block of code between the curly braces ( `{` and
`}` ) is executed - but only if the condition is true. The condition
in the above example is `!self.onGround` (self is not on ground) which
in the above example is `!self.onGround` (self is _not_ on ground) which
will be `true` if you are currently flying or `false` if you aren't.
What if you wanted to display a message only if a condition is *not*
@ -1077,29 +1035,29 @@ following code sends a message to any player who breaks a block in the
game...
```javascript
function myBlockDestroyHook( event ){
function myBlockBreakHook( event ){
var breaker = event.player;
echo( breaker, 'You broke a block');
}
events.blockDestroy( myBlockDestroyHook );
events.blockBreak( myBlockBreakHook );
```
The `events.blockDestroy()` function is just one of the many `events` functions which can be used to *register* a function to be called whenever a particular type of event occurs. In the
above code the blockDestroy function takes as a parameter a function
The `events.blockBreak()` function is just one of the many `events` functions which can be used to *register* a function to be called whenever a particular type of event occurs. In the
above code the blockBreak function takes as a parameter a function
I want to be called when that event occurs. The function I want called
in turn takes 1 parameter. The `event` object has all the information
about the event which just occurred. I can tell who broke the block
and send a message to the player. The important thing to note is that
the `myBlockDestroyHook` function defined above will not be called until a player breaks a
the `myBlockBreakHook` function defined above will not be called until a player breaks a
block. Try it - save the above code in a new file in the
`scriptcraft/plugins` directory then type `/js refresh()` to reload
scriptcraft. Then break a block in the game and you should see the
message 'You broke a block'.
There are many types of events you can listen for in Minecraft. You can
browse [all possible event registration functions][cmevts2] in the API Reference.
browse [all possible event registration functions][spevts2] in the API Reference.
For custom events (events which aren't in the net.canarymod.hook tree)
For custom events (events which aren't in the org.bukkit.event tree)
just specify the fully qualified class name instead. E.g. ...