2013-01-08 01:48:09 +01:00
|
|
|
load(__folder + "drone.js"); // assumes cottage.js and drone.js are in same directory
|
2013-01-01 21:33:59 +01:00
|
|
|
//
|
|
|
|
// need to use the drone module to create buildings easily
|
|
|
|
// it can be done using calls to putBlock(), putSign(), getPlayerPos() and getMousePos()
|
|
|
|
// but it's easier to use the Drone class
|
2013-01-08 01:48:09 +01:00
|
|
|
// __folder is a special javascript variable whose value is the directory where the
|
2013-01-01 21:33:59 +01:00
|
|
|
// current script resides.
|
|
|
|
//
|
|
|
|
// usage:
|
|
|
|
// [1] to build a cottage at the player's current location or the cross-hairs location...
|
|
|
|
//
|
|
|
|
// /js cottage();
|
|
|
|
//
|
|
|
|
// [2] to build a cottage using an existing drone...
|
|
|
|
//
|
2013-01-01 23:38:16 +01:00
|
|
|
// /js drone.cottage();
|
2013-01-01 21:33:59 +01:00
|
|
|
//
|
|
|
|
|
2013-01-01 23:38:16 +01:00
|
|
|
Drone.extend('cottage',function ()
|
2013-01-01 21:33:59 +01:00
|
|
|
{
|
2013-01-01 23:38:16 +01:00
|
|
|
this.chkpt('cottage')
|
2013-01-01 21:33:59 +01:00
|
|
|
.box0(48,7,2,6) // 4 walls
|
|
|
|
.right(3).door() // door front and center
|
|
|
|
.up(1).left(2).box(102) // windows to left and right
|
|
|
|
.right(4).box(102)
|
|
|
|
.left(5).up().prism0(53,7,6);
|
|
|
|
//
|
|
|
|
// put up a sign near door.
|
|
|
|
//
|
2013-01-01 23:38:16 +01:00
|
|
|
this.down().right(4).sign(["Home","Sweet","Home"],68);
|
2013-01-01 21:33:59 +01:00
|
|
|
|
2013-01-01 23:38:16 +01:00
|
|
|
return this.move('cottage');
|
|
|
|
});
|
2013-01-01 21:33:59 +01:00
|
|
|
//
|
|
|
|
// a more complex script that builds an tree-lined avenue with
|
|
|
|
// cottages on both sides.
|
|
|
|
//
|
2013-01-01 23:38:16 +01:00
|
|
|
Drone.extend('cottage_road', function(numberCottages)
|
2013-01-01 21:33:59 +01:00
|
|
|
{
|
|
|
|
if (typeof numberCottages == "undefined"){
|
|
|
|
numberCottages = 6;
|
|
|
|
}
|
|
|
|
var i=0, distanceBetweenTrees = 11;
|
|
|
|
//
|
|
|
|
// step 1 build the road.
|
|
|
|
//
|
|
|
|
var cottagesPerSide = Math.floor(numberCottages/2);
|
2013-01-01 23:38:16 +01:00
|
|
|
this
|
2013-01-01 21:33:59 +01:00
|
|
|
.chkpt("cottage_road") // make sure the drone's state is saved.
|
|
|
|
.box(43,3,1,cottagesPerSide*(distanceBetweenTrees+1)) // build the road
|
|
|
|
.up().right() // now centered in middle of road
|
|
|
|
.chkpt("cr"); // will be returning to this position later
|
|
|
|
|
|
|
|
//
|
|
|
|
// step 2 line the road with trees
|
|
|
|
//
|
|
|
|
for (; i < cottagesPerSide+1;i++){
|
2013-01-01 23:38:16 +01:00
|
|
|
this
|
2013-01-01 21:33:59 +01:00
|
|
|
.left(5).oak()
|
|
|
|
.right(10).oak()
|
|
|
|
.left(5) // return to middle of road
|
|
|
|
.fwd(distanceBetweenTrees+1); // move forward.
|
|
|
|
}
|
2013-01-01 23:38:16 +01:00
|
|
|
this.move("cr").back(6); // move back 1/2 the distance between trees
|
2013-01-01 21:33:59 +01:00
|
|
|
|
|
|
|
// this function builds a path leading to a cottage.
|
|
|
|
function pathAndCottage(d){
|
2013-01-01 23:38:16 +01:00
|
|
|
return d.down().box(43,1,1,5).fwd(5).left(3).up().cottage();
|
2013-01-01 21:33:59 +01:00
|
|
|
};
|
|
|
|
//
|
|
|
|
// step 3 build cottages on each side
|
|
|
|
//
|
|
|
|
for (i = 0;i < cottagesPerSide; i++)
|
|
|
|
{
|
2013-01-01 23:38:16 +01:00
|
|
|
this.fwd(distanceBetweenTrees+1).chkpt("r"+i);
|
2013-01-01 21:33:59 +01:00
|
|
|
// build cottage on left
|
2013-01-01 23:38:16 +01:00
|
|
|
pathAndCottage(this.turn(3)).move("r"+i);
|
2013-01-01 21:33:59 +01:00
|
|
|
// build cottage on right
|
2013-01-01 23:38:16 +01:00
|
|
|
pathAndCottage(this.turn()).move("r"+i);
|
2013-01-01 21:33:59 +01:00
|
|
|
}
|
|
|
|
// return drone to where it was at start of function
|
2013-01-01 23:38:16 +01:00
|
|
|
return this.move("cottage_road");
|
|
|
|
});
|
2013-01-01 21:33:59 +01:00
|
|
|
|