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
//

View file

@ -1,13 +1,10 @@
var scriptDir = $SCRIPT_DIR;
load(scriptDir + "/drone.js"); // assumes cottage.js and drone.js are in same directory
load(__folder + "drone.js"); // assumes cottage.js and drone.js are in same directory
//
// 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
// $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.
// $SCRIPT is a special javascript variable whose value is the full name of the current script.
//
//
// usage:
// [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.
// 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();
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(){
while(true){
var discoTicks = 30;
var strobe = function()
{
while(discoTicks--)
{
disco.rand(floorTiles,width,1,length);
java.lang.Thread.sleep(1000);
}

View file

@ -1,4 +1,4 @@
var ScriptCraft = ScriptCraft || {};
load(__folder + "../core/_primitives.js");
var global = this;
//
// Interface
@ -251,22 +251,22 @@ var Drone = Drone || {
//
// don't want to declare object more than once
//
if (ScriptCraft.Drone){
if (Drone.constructor == Function)
return;
}
//
// Drone Constructor
//
var Drone = function(x,y,z,dir)
Drone = function(x,y,z,dir)
{
var usePlayerCoords = false;
var playerPos = getPlayerPos();
if (typeof x == "undefined"){
var mp = getMousePos();
if (mp){
this.x = mp[0];
this.y = mp[1];
this.z = mp[2];
this.x = mp.x;
this.y = mp.y;
this.z = mp.z;
}else{
// base it on the player's current location
usePlayerCoords = true;
@ -277,9 +277,9 @@ var Drone = Drone || {
if (!playerPos){
return null;
}
this.x = playerPos[0];
this.y = playerPos[1];
this.z = playerPos[2];
this.x = playerPos.x;
this.y = playerPos.y;
this.z = playerPos.z;
}
}else{
this.x = x;
@ -287,7 +287,7 @@ var Drone = Drone || {
this.z = z;
}
if (typeof dir == "undefined"){
this.dir = _getDirFromRotation(playerPos[3]);
this.dir = _getDirFromRotation(playerPos.yaw);
}else{
this.dir = dir%4;
}
@ -885,7 +885,6 @@ var Drone = Drone || {
};
Drone.prototype.cylinder0 = _cylinder0;
Drone.prototype.cylinder = _cylinder1;
ScriptCraft.Drone = Drone;
//
// 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
//

View file

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