fix for issue #86

This commit is contained in:
walterhiggins 2013-07-28 10:54:08 +01:00
parent 8a9ce400c2
commit b08b112107
2 changed files with 113 additions and 65 deletions

View file

@ -262,7 +262,7 @@ ScriptCraft's Drone can do, read on...
Constructing a Drone Object Constructing a Drone Object
=========================== ===========================
Drones can be created in 3 ways... Drones can be created in any of the following ways...
1. Calling any one of the methods listed below will return a Drone object. For example... 1. Calling any one of the methods listed below will return a Drone object. For example...
@ -305,7 +305,7 @@ Drones can be created in 3 ways...
around this by pointing at a 'corner stone' just above ground around this by pointing at a 'corner stone' just above ground
level or alternatively use the following statement... level or alternatively use the following statement...
d = new Drone().up() d = new Drone().up();
... which will move the drone up one block as soon as it's created. ... which will move the drone up one block as soon as it's created.
@ -313,7 +313,7 @@ Drones can be created in 3 ways...
3. Or by using the following form... 3. Or by using the following form...
d = new Drone(x,y,z,direction) d = new Drone(x,y,z,direction,world);
This will create a new Drone at the location you specified using This will create a new Drone at the location you specified using
x, y, z In minecraft, the X axis runs west to east and the Z axis runs x, y, z In minecraft, the X axis runs west to east and the Z axis runs
@ -322,8 +322,27 @@ Drones can be created in 3 ways...
direction parameter is omitted, the player's direction is used direction parameter is omitted, the player's direction is used
instead. instead.
Both the `direction` and `world` parameters are optional.
4. Create a new Drone based on a Bukkit Location object...
d = new Drone(location);
This is useful when you want to create a drone at a given
`org.bukkit.Location` . The `Location` class is used throughout
the bukkit API. For example, if you want to create a drone when a
block is broken at the block's location you would do so like
this...
events.on('block.BlockBreakEvent',function(listener,event){
var location = event.block.location;
var drone = new Drone(location);
// do more stuff with the drone here...
});
Parameters Parameters
---------- ----------
* location (optional) : *NB* If an `org.bukkit.Location` object is provided as a parameter, then it should be the only parameter.
* x (optional) : The x coordinate of the Drone * x (optional) : The x coordinate of the Drone
* y (optional) : The y coordinate of the Drone * y (optional) : The y coordinate of the Drone
* z (optional) : The z coordinate of the Drone * z (optional) : The z coordinate of the Drone
@ -920,23 +939,6 @@ To create a 2-line high message using glowstone...
[imgbt1]: img/blocktype1.png [imgbt1]: img/blocktype1.png
Drone.rainbow() method
======================
Creates a Rainbow.
Parameters
----------
* radius (optional - default:18) - The radius of the rainbow
Example
-------
var d = new Drone();
d.rainbow(30);
![rainbow example](img/rainbowex1.png)
Blocks Module Blocks Module
============= =============
You hate having to lookup [Data Values][dv] when you use ScriptCraft's Drone() functions. So do I. You hate having to lookup [Data Values][dv] when you use ScriptCraft's Drone() functions. So do I.
@ -949,35 +951,7 @@ Examples
box( blocks.sand, 3, 2, 1 ); // creates a block of sand 3 wide x 2 high x 1 long box( blocks.sand, 3, 2, 1 ); // creates a block of sand 3 wide x 2 high x 1 long
box( blocks.wool.green, 2 ); // creates a block of green wool 2 blocks wide box( blocks.wool.green, 2 ); // creates a block of green wool 2 blocks wide
In addition, there's a convenience array `blocks.rainbow` which is an array of the 7 colors of the rainbow (or closest approximations). Color aliased properties that were a direct descendant of the blocks object are no longer used to avoid confusion with carpet and stained clay blocks. In addition, there's a convenience array `blocks.rainbow` which is an array of the 7 colors of the rainbow (or closest approximations).
Drone.spiral_stairs() method
============================
Constructs a spiral staircase with slabs at each corner.
Parameters
----------
* stairBlock - The block to use for stairs, should be one of the following...
- 'oak'
- 'spruce'
- 'birch'
- 'jungle'
- 'cobblestone'
- 'brick'
- 'stone'
- 'nether'
- 'sandstone'
- 'quartz'
* flights - The number of flights of stairs to build.
![Spiral Staircase](img/spiralstair1.png)
Example
-------
To construct a spiral staircase 5 floors high made of oak...
spiral_stairs('oak', 5);
Drone.sphere() method Drone.sphere() method
===================== =====================
@ -1057,6 +1031,51 @@ To create a glass 'north' hemisphere with a radius of 20 blocks...
![hemisphere example](img/hemisphereex2.png) ![hemisphere example](img/hemisphereex2.png)
Drone.rainbow() method
======================
Creates a Rainbow.
Parameters
----------
* radius (optional - default:18) - The radius of the rainbow
Example
-------
var d = new Drone();
d.rainbow(30);
![rainbow example](img/rainbowex1.png)
Drone.spiral_stairs() method
============================
Constructs a spiral staircase with slabs at each corner.
Parameters
----------
* stairBlock - The block to use for stairs, should be one of the following...
- 'oak'
- 'spruce'
- 'birch'
- 'jungle'
- 'cobblestone'
- 'brick'
- 'stone'
- 'nether'
- 'sandstone'
- 'quartz'
* flights - The number of flights of stairs to build.
![Spiral Staircase](img/spiralstair1.png)
Example
-------
To construct a spiral staircase 5 floors high made of oak...
spiral_stairs('oak', 5);
Classroom Module Classroom Module
================ ================
The `classroom` object contains a couple of utility functions for use The `classroom` object contains a couple of utility functions for use

View file

@ -32,7 +32,7 @@ ScriptCraft's Drone can do, read on...
Constructing a Drone Object Constructing a Drone Object
=========================== ===========================
Drones can be created in 3 ways... Drones can be created in any of the following ways...
1. Calling any one of the methods listed below will return a Drone object. For example... 1. Calling any one of the methods listed below will return a Drone object. For example...
@ -75,7 +75,7 @@ Drones can be created in 3 ways...
around this by pointing at a 'corner stone' just above ground around this by pointing at a 'corner stone' just above ground
level or alternatively use the following statement... level or alternatively use the following statement...
d = new Drone().up() d = new Drone().up();
... which will move the drone up one block as soon as it's created. ... which will move the drone up one block as soon as it's created.
@ -83,7 +83,7 @@ Drones can be created in 3 ways...
3. Or by using the following form... 3. Or by using the following form...
d = new Drone(x,y,z,direction) d = new Drone(x,y,z,direction,world);
This will create a new Drone at the location you specified using This will create a new Drone at the location you specified using
x, y, z In minecraft, the X axis runs west to east and the Z axis runs x, y, z In minecraft, the X axis runs west to east and the Z axis runs
@ -92,8 +92,27 @@ Drones can be created in 3 ways...
direction parameter is omitted, the player's direction is used direction parameter is omitted, the player's direction is used
instead. instead.
Both the `direction` and `world` parameters are optional.
4. Create a new Drone based on a Bukkit Location object...
d = new Drone(location);
This is useful when you want to create a drone at a given
`org.bukkit.Location` . The `Location` class is used throughout
the bukkit API. For example, if you want to create a drone when a
block is broken at the block's location you would do so like
this...
events.on('block.BlockBreakEvent',function(listener,event){
var location = event.block.location;
var drone = new Drone(location);
// do more stuff with the drone here...
});
Parameters Parameters
---------- ----------
* location (optional) : *NB* If an `org.bukkit.Location` object is provided as a parameter, then it should be the only parameter.
* x (optional) : The x coordinate of the Drone * x (optional) : The x coordinate of the Drone
* y (optional) : The y coordinate of the Drone * y (optional) : The y coordinate of the Drone
* z (optional) : The z coordinate of the Drone * z (optional) : The z coordinate of the Drone
@ -703,19 +722,29 @@ Used when placing torches so that they face towards the drone.
this.z = playerPos.z; this.z = playerPos.z;
this.world = playerPos.world; this.world = playerPos.world;
} }
}else{
if (arguments[0] instanceof org.bukkit.Location){
this.x = arguments[0].x;
this.y = arguments[0].y;
this.z = arguments[0].z;
this.dir = _getDirFromRotation(arguments[0].yaw);
this.world = arguments[0].world;
}else{ }else{
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
this.world = _getWorld();
}
if (typeof dir == "undefined"){ if (typeof dir == "undefined"){
this.dir = _getDirFromRotation(playerPos.yaw); this.dir = _getDirFromRotation(playerPos.yaw);
}else{ }else{
this.dir = dir%4; this.dir = dir%4;
} }
if (typeof world !== "undefined") if (typeof world == "undefined"){
this.world = _getWorld();
}else{
this.world = world; this.world = world;
}
}
}
// for debugging // for debugging
//self.sendMessage("New Drone " + this.toString()); //self.sendMessage("New Drone " + this.toString());