This commit is contained in:
walterhiggins 2013-01-08 00:48:09 +00:00
parent 23794e985a
commit 1c041d73da
6 changed files with 24 additions and 34 deletions

View file

@ -1,4 +1,4 @@
load($SCRIPT_DIR + "/fort.js"); load(__folder + "fort.js");
// //
// a castle is just a big wide fort with 4 taller forts at each corner // a castle is just a big wide fort with 4 taller forts at each corner
// //

View file

@ -1,13 +1,10 @@
var scriptDir = $SCRIPT_DIR; load(__folder + "drone.js"); // assumes cottage.js and drone.js are in same directory
load(scriptDir + "/drone.js"); // assumes cottage.js and drone.js are in same directory
// //
// need to use the drone module to create buildings easily // need to use the drone module to create buildings easily
// it can be done using calls to putBlock(), putSign(), getPlayerPos() and getMousePos() // it can be done using calls to putBlock(), putSign(), getPlayerPos() and getMousePos()
// but it's easier to use the Drone class // but it's easier to use the Drone class
// $SCRIPT_DIR is a special javascript variable whose value is the directory where the // __folder is a special javascript variable whose value is the directory where the
// current script resides. // current script resides.
// $SCRIPT is a special javascript variable whose value is the full name of the current script.
//
// //
// usage: // usage:
// [1] to build a cottage at the player's current location or the cross-hairs location... // [1] to build a cottage at the player's current location or the cross-hairs location...

View file

@ -1,4 +1,4 @@
load($SCRIPT_DIR + "/drone.js"); load(__folder + "drone.js");
// //
// Create a floor of colored tiles some of which emit light. // Create a floor of colored tiles some of which emit light.
// The tiles change color every second creating a strobe-lit dance-floor. // The tiles change color every second creating a strobe-lit dance-floor.
@ -21,10 +21,13 @@ Drone.extend('dancefloor',function(width,length)
disco.down().box(89,width,1,length).up(); disco.down().box(89,width,1,length).up();
var floorTiles = [35,35,'35:1','35:2','35:3','35:4','35:4','35:4','35:6',20,20]; var floorTiles = [35,35,'35:1','35:2','35:3','35:4','35:4','35:4','35:6',20,20];
// //
// strobe gets called in a java thread // strobe gets called in a java thread - disco only lasts 30 seconds.
// //
var strobe = function(){ var discoTicks = 30;
while(true){ var strobe = function()
{
while(discoTicks--)
{
disco.rand(floorTiles,width,1,length); disco.rand(floorTiles,width,1,length);
java.lang.Thread.sleep(1000); java.lang.Thread.sleep(1000);
} }

View file

@ -1,4 +1,4 @@
var ScriptCraft = ScriptCraft || {}; load(__folder + "../core/_primitives.js");
var global = this; var global = this;
// //
// Interface // Interface
@ -251,22 +251,22 @@ var Drone = Drone || {
// //
// don't want to declare object more than once // don't want to declare object more than once
// //
if (ScriptCraft.Drone){ if (Drone.constructor == Function)
return; return;
}
// //
// Drone Constructor // Drone Constructor
// //
var Drone = function(x,y,z,dir) Drone = function(x,y,z,dir)
{ {
var usePlayerCoords = false; var usePlayerCoords = false;
var playerPos = getPlayerPos(); var playerPos = getPlayerPos();
if (typeof x == "undefined"){ if (typeof x == "undefined"){
var mp = getMousePos(); var mp = getMousePos();
if (mp){ if (mp){
this.x = mp[0]; this.x = mp.x;
this.y = mp[1]; this.y = mp.y;
this.z = mp[2]; this.z = mp.z;
}else{ }else{
// base it on the player's current location // base it on the player's current location
usePlayerCoords = true; usePlayerCoords = true;
@ -277,9 +277,9 @@ var Drone = Drone || {
if (!playerPos){ if (!playerPos){
return null; return null;
} }
this.x = playerPos[0]; this.x = playerPos.x;
this.y = playerPos[1]; this.y = playerPos.y;
this.z = playerPos[2]; this.z = playerPos.z;
} }
}else{ }else{
this.x = x; this.x = x;
@ -287,7 +287,7 @@ var Drone = Drone || {
this.z = z; this.z = z;
} }
if (typeof dir == "undefined"){ if (typeof dir == "undefined"){
this.dir = _getDirFromRotation(playerPos[3]); this.dir = _getDirFromRotation(playerPos.yaw);
}else{ }else{
this.dir = dir%4; this.dir = dir%4;
} }
@ -885,7 +885,6 @@ var Drone = Drone || {
}; };
Drone.prototype.cylinder0 = _cylinder0; Drone.prototype.cylinder0 = _cylinder0;
Drone.prototype.cylinder = _cylinder1; Drone.prototype.cylinder = _cylinder1;
ScriptCraft.Drone = Drone;
// //
// make all Drone's methods available also as standalone functions // make all Drone's methods available also as standalone functions
@ -914,12 +913,3 @@ var Drone = Drone || {
} }
}()); }());
Drone = ScriptCraft.Drone;
/*
getPlayerPos = function(){return {x:0,y:0,z:0,rotationYaw:0};};
getMousePos = function(){return null;};
putBlock = function(){};
getBlock = function(){};
drone.copy('x',4,2,3);
*/
drone = new Drone();

View file

@ -1,4 +1,4 @@
load($SCRIPT_DIR + "/drone.js"); load(__folder + "drone.js");
// //
// constructs a medieval fort // constructs a medieval fort
// //

View file

@ -1,4 +1,4 @@
load($SCRIPT_DIR + "/drone.js"); load(__folder + "drone.js");
// //
// constructs a mayan temple // constructs a mayan temple
// //
@ -21,4 +21,4 @@ Drone.extend('temple', function(side) {
} }
return this.move('temple'); return this.move('temple');
}); });