Skip to content

Commit 795043c

Browse files
committed
changed for canarymod
1 parent 80522b6 commit 795043c

2 files changed

Lines changed: 130 additions & 128 deletions

File tree

docs/YoungPersonsGuideToProgrammingMinecraft.md

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,33 @@ players connect to a Minecraft Server on the internet or locally
5656

5757
## Installation
5858

59-
CraftBukkit is a version of the Minecraft server software which allows
59+
CanaryMod is a version of the Minecraft server software which allows
6060
easy addition of 'Mods' and extensions to Minecraft. ScriptCraft is a
61-
'Mod' for use with CraftBukkit. Adding Mods to Minecraft can be
62-
difficult but CraftBukkit makes it easy. Follow these steps to
61+
'Mod' for use with CanaryMod. Adding Mods to Minecraft can be
62+
difficult but CanaryMod makes it easy. Follow these steps to
6363
Install ScriptCraft on your computer...
6464

65-
1. [Download and install CraftBukkit][dlbuk2] (choose either Recommended, Beta or Development) . Then follow the [Bukkit
66-
Installation Instructions][bii]. (Tip: You can grab the very latest
67-
version of bukkit from the [alternative versions list][dlbuk2])
65+
1. [Download and install CanaryMod][dlcm] (choose either Recommended, Beta or Development) . Then follow the [CanaryMod
66+
Installation Instructions][cmadmin].
6867

69-
2. Start the CraftBukkit server, then once it has started up, stop it
70-
by typing 'stop'. If you go to the craftbukkit folder (see step 1) you
68+
2. Start the CanaryMod server, then once it has started up, stop it
69+
by typing 'stop'. If you go to the CanaryMod folder (see step 1) you
7170
should see some new files and subfolders.
7271

7372
3. [Download the latest version of the ScriptCraft Mod][sc-plugin]. Then copy the ScriptCraft.jar file to the
74-
`craftbukkit/plugins` folder (This folder won't be created until you run Bukkit for the first time (see previous step).
73+
`plugins` folder (This folder won't be created until you run CanaryMod for the first time (see previous step).
7574

76-
4. Start up the craftbukkit server again (see [instructions for starting the server][bii]).
75+
4. Start up the CanaryMod server again (see [instructions for starting the server][cmadmin]).
7776

78-
5. In the CraftBukkit command window type `op {your_username}` and hit
77+
5. In the CanaryMod command window type `op {your_username}` and hit
7978
enter, replacing {your_username} with your own minecraft
8079
username. This will give you `operator` access meaning you can perform
8180
more commands than are normally available in Minecraft. You should
8281
make yourself a server operator (Server operators have full privileges
83-
for the server) permanently by editing the craftbukkit/ops.txt file
82+
for the server) permanently by editing the ops.txt file
8483
and adding your username (one username per line).
8584

86-
6. In the CraftBukkit command window type `js 1 + 1` and hit enter. You should see `> 2` .
85+
6. In the CanaryMod command window type `js 1 + 1` and hit enter. You should see `> 2` .
8786

8887
... Congratulations! You just installed your own Minecraft Server with
8988
the ScriptCraft Mod and are now ready to begin programming in Minecraft.
@@ -98,9 +97,9 @@ interactive web sites and many other applications.
9897

9998
## Configuring your Server (optional)
10099

101-
Once you've installed CraftBukkit, depending on your specific needs,
100+
Once you've installed CanaryMod, depending on your specific needs,
102101
you might want to consider setting the following properties in the
103-
`server.properties` file...
102+
`server.properties` or `world.properties` files...
104103

105104
# completely flat worlds are best for building from scratch
106105
level-type=FLAT
@@ -139,8 +138,8 @@ Minecraft server and are ready to connect ...
139138
4. Type any name you like in the name field then type `localhost` in the
140139
address field. `localhost` is a special internet address that points to
141140
your own computer.
142-
5. Click 'Join Server' to join the craftbukkit server. If the version
143-
of Minecraft is incompatible with the version of CraftBukkit you will
141+
5. Click 'Join Server' to join the server. If the version
142+
of Minecraft is incompatible with the version of the server you will
144143
not be able to connect to the server. To fix this, you can create a
145144
Minecraft profile in your client. Profiles let you decide which
146145
version of Minecraft client you want to run so that your client and
@@ -188,7 +187,7 @@ value like this...
188187
The `var` keyword is only needed when you first create the variable. Now
189188
execute this command...
190189

191-
/js echo( location )
190+
/js echo( self, location )
192191

193192
...and it displays...
194193

@@ -199,11 +198,11 @@ the variables you'll create in your in-game commands and scripts, there
199198
are handy *free* variables created for you by ScriptCraft. One such variable is
200199
`self`, it contains information about the current player (that's you)...
201200

202-
/js echo ( self )
201+
/js echo ( self, self.name )
203202

204-
... displays the following...
203+
... displays something like the following...
205204

206-
CraftPlayer{name=walterh}
205+
walterh
207206

208207
... for me but the message displayed will be different for every player.
209208

@@ -217,15 +216,15 @@ looking at the building functions let's look at the `echo()` function.
217216
`echo()` - as its name implies - will echo back at you whatever you
218217
tell it. For example, type ...
219218

220-
/js echo('Hello')
219+
/js echo( self, 'Hello')
221220

222221
... and the game will display...
223222

224223
Hello
225224

226225
... type ...
227226

228-
/js echo( 5 + 7 )
227+
/js echo( self, 5 + 7 )
229228

230229
... and the game will display...
231230

@@ -235,7 +234,7 @@ tell it. For example, type ...
235234
don't recommend it. Homework and Minecraft don't mix! The `echo()`
236235
function will display anything you tell it to - Text, Numbers and other types...
237236

238-
/js echo( new Date() )
237+
/js echo( self, new Date() )
239238

240239
... prints today's date. If the statement above looks confusing - don't
241240
worry - `new Date()` creates a new date object - I'll talk about objects
@@ -502,12 +501,12 @@ Once you've installed Notepad++, Launch it, create a new file and type the follo
502501

503502
```javascript
504503
exports.greet = function( player ) {
505-
player.sendMessage('Hi ' + player.name);
504+
echo( player, 'Hi ' + player.name);
506505
}
507506
```
508507

509508
... then save the file in a new directory
510-
`craftbukkit/plugins/scriptcraft/plugins/{your_name}` (replace
509+
`scriptcraft/plugins/{your_name}` (replace
511510
{your_name} with your own name) and call the file `greet.js` (be sure
512511
to change the file-type option to '*.* All Files' when saving or
513512
NotePad++ will add a '.txt' extension to the filename. Now switch back
@@ -528,7 +527,7 @@ loaded. Try it out by typing this command...
528527
minecraft username. Congratulations - You've just written your very
529528
first Minecraft Mod! With ScriptCraft installed, writing Minecraft
530529
Mods is as simple as writing a new javascript function and saving it
531-
in a file in the craftbukkit/plugins/scriptcraft/plugins
530+
in a file in the scriptcraft/plugins
532531
directory. This function will now be avaible every time you launch
533532
minecraft. This is a deliberately trivial minecraft mod but the
534533
principles are the same when creating more complex mods.
@@ -543,17 +542,17 @@ one or more functions, objects or variables. For example...
543542
#### thrower.js
544543

545544
```javascript
546-
exports.egg = function(player){
547-
player.throwEgg();
545+
exports.boo = function(player){
546+
echo( player, 'Boo!');
548547
}
549-
exports.snowball = function(player){
550-
player.throwSnowball();
548+
exports.yo = function(player){
549+
echo( player, 'Yo!');
551550
}
552551
```
553552

554-
... is a plugin which provides 2 javascript functions called `egg()`
555-
and `snowball()` which can be invoked from the in-game prompt like
556-
this `/js egg(self)` or `/js snowball(self)`.
553+
... is a plugin which provides 2 javascript functions called `boo()`
554+
and `yo()` which can be invoked from the in-game prompt like
555+
this `/js boo(self)` or `/js yo(self)`.
557556

558557
## Parameters
559558
If you want to change the `greet()` function so that it displays a
@@ -568,7 +567,7 @@ Change the `greet()` function so that it looks like this...
568567

569568
```javascript
570569
exports.greet = function ( greeting , player) {
571-
player.sendMessage( greeting + player.name );
570+
echo( player, greeting + player.name );
572571
}
573572
```
574573

@@ -635,6 +634,8 @@ things...
635634
compare the ages of your friends or siblings to your own age.
636635

637636
## More fun with `true` or `false`
637+
TODO: This needs to be changed for CanaryMod
638+
638639
You can find out if you can Fly in minecraft by typing the following statement...
639640

640641
/js self.allowFlight
@@ -669,7 +670,7 @@ expected...
669670
... This statement won't work as expected - it will give an Error
670671
message. This is because sometimes we can read variables but we can't
671672
change them the same way we read them (this is because of how
672-
Javascript, Java and the CraftBukkit API work together). To turn on or
673+
Javascript, Java and the CanaryMod API work together). To turn on or
673674
off the spawning of monsters, type the following...
674675

675676
/js self.location.world.setSpawnFlags(false, true)
@@ -680,8 +681,8 @@ whether or not Animals can spawn. (SIDENOTE: You may be wondering how
680681
to change other aspects of the Minecraft game - pretty much all
681682
aspects of the game can be changed. Changes are made using what are
682683
called `API` calls - these are calls to functions and methods in
683-
Minecraft - you can read more about these on the [CraftBukkit API
684-
Reference][cbapi].)
684+
Minecraft - you can read more about these on the [CanaryMod API
685+
Reference][cmapi].)
685686

686687
## ...and Again, and Again, and Again,...
687688

@@ -722,26 +723,24 @@ connnected to a server, the worlds of a server and so on.
722723

723724
At the in-game command prompt type the following then hit Enter...
724725

725-
/js for (var i = 0;i < server.onlinePlayers.length; i++){ server.onlinePlayers[i].sendMessage('Hi!'); }
726+
/js var utils = require('utils');
727+
/js var players = utils.players();
728+
/js for (var i = 0;i < players.length; i++){ echo(players[i], 'Hi!'); }
726729

727730
... Lets look at these statements in more detail. We had to enter the
728731
statements on a single line at the in-game command prompt but the
729732
statements could be written like this...
730733

731734
```javascript
732-
var players = server.onlinePlayers;
733-
var player;
734-
var i;
735-
for ( i = 0; i < players.length; i++ ) {
736-
player = players[i];
737-
player.sendMessage( 'Hi!' );
735+
var utils = require('utils');
736+
var players = utils.players();
737+
for (var i = 0;i < players.length; i++) {
738+
echo(players[i], 'Hi!');
738739
}
739740
```
740741

741-
... On the first line, a new variable `players` is created from the
742-
server object's onlinePlayers property. `players` is more concise and
743-
easier to type than the long-winded `server.onlinePlayers`. On the
744-
fourth line, the for loop is declared, a counter variable `i` is set
742+
... On the 2nd line, a new variable `players` is created and assigned a value by calling utils.players().
743+
On the next line, the for loop is declared, a counter variable `i` is set
745744
to 0 (zero - arrays in javascript start at 0 not 1) and each time
746745
around the loop is tested to see if it's less than the number of
747746
players online. At the end of each run around the loop the `i`
@@ -766,18 +765,19 @@ TextWrangler or your editor of choice) and add the following code at
766765
the bottom of the file...
767766

768767
```javascript
768+
var utils = require('utils');
769769
exports.hiAll = function () {
770-
var players = server.onlinePlayers,
771-
player,
772-
i;
773-
for ( i = 0; i < players.length; i++) {
774-
player = players[i];
775-
player.sendMessage( 'Hi!' );
776-
}
770+
var players = utils.players();
771+
player,
772+
i;
773+
for ( i = 0; i < players.length; i++) {
774+
player = players[i];
775+
echo( player, 'Hi!' );
776+
}
777777
}
778778
```
779779

780-
... save the file, at the in-game command prompt type `reload` and
780+
... save the file, at the in-game command prompt type `js refresh()` and
781781
then type `/js hiAll()`. This will send the message `Hi!` to all of
782782
the players connected to your server. You've done this using a `for`
783783
loop and arrays. Arrays and `for` loops are used heavily in all types
@@ -885,7 +885,7 @@ utils.foreach( server.onlinePlayers, function( player ) {
885885

886886
### Exercise
887887
Try changing the above function so that different sounds are played
888-
instead of a Cat's Meow. You'll need to lookup the [CraftBukkit API's
888+
instead of a Cat's Meow. You'll need to lookup the [CanaryMod API's
889889
Sound class][soundapi] to see all of the possible sounds that can be
890890
played.
891891

@@ -1266,23 +1266,24 @@ covered here. If you want to dive deeper into programming and modding
12661266
minecraft, I recommend reading the accompanying [ScriptCraft API
12671267
reference][api] which covers all of the ScriptCraft functions, objects
12681268
and methods. I also recommend reading the source code to some of the
1269-
existing scriptcraft add-ons, the *chat* module (
1270-
`scriptcraft/plugins/chat/color.js` ) is a good place to start, followed by
1271-
[Anatomy of a ScriptCraft Plug-in][ap]. The online [Craftbukkit API
1272-
Reference][cbapi] provides lots of valuable information about the
1269+
existing scriptcraft plugins, followed by
1270+
[Anatomy of a ScriptCraft Plug-in][ap]. The online [CanaryMod API
1271+
Reference][cmapi] provides lots of valuable information about the
12731272
different objects and methods available for use by ScriptCraft.
12741273

12751274

1276-
[buk]: http://wiki.bukkit.org/Setting_up_a_server
1275+
[cmadmin]: http://canarymod.net/books/canarymod-admin-guide
12771276
[dlbuk2]: http://dl.bukkit.org/downloads/craftbukkit/
1277+
[dlcm]: http://canarymod.net/releases
12781278
[bii]: http://wiki.bukkit.org/Setting_up_a_server
12791279
[sc-plugin]: http://scriptcraftjs.org/download/
12801280
[ce]: http://www.codecademy.com/
12811281
[mcdv]: http://www.minecraftwiki.net/wiki/Data_values
12821282
[np]: http://notepad-plus-plus.org/
12831283
[cbapi]: http://jd.bukkit.org/beta/apidocs/
1284+
[cmapi]: https://ci.visualillusionsent.net/job/CanaryLib/javadoc/
12841285
[boole]: http://en.wikipedia.org/wiki/George_Boole
1285-
[soundapi]: http://jd.bukkit.org/beta/apidocs/org/bukkit/Sound.html
1286+
[soundapi]: https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/api/world/effects/SoundEffect.Type.html
12861287
[ap]: Anatomy-of-a-Plugin.md
12871288
[api]: API-Reference.md
12881289
[twl]: http://www.barebones.com/products/textwrangler/

0 commit comments

Comments
 (0)