From 1c041d73dae5e6e4985d07fed88495ecc759e375 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Tue, 8 Jan 2013 00:48:09 +0000 Subject: [PATCH] updated --- js-plugins/drone/castle.js | 2 +- js-plugins/drone/cottage.js | 7 ++----- js-plugins/drone/dancefloor.js | 11 +++++++---- js-plugins/drone/drone.js | 32 +++++++++++--------------------- js-plugins/drone/fort.js | 2 +- js-plugins/drone/temple.js | 4 ++-- 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/js-plugins/drone/castle.js b/js-plugins/drone/castle.js index ec8859c..3337c7e 100644 --- a/js-plugins/drone/castle.js +++ b/js-plugins/drone/castle.js @@ -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 // diff --git a/js-plugins/drone/cottage.js b/js-plugins/drone/cottage.js index 5643278..93189fc 100644 --- a/js-plugins/drone/cottage.js +++ b/js-plugins/drone/cottage.js @@ -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... diff --git a/js-plugins/drone/dancefloor.js b/js-plugins/drone/dancefloor.js index d594df2..44c45c1 100644 --- a/js-plugins/drone/dancefloor.js +++ b/js-plugins/drone/dancefloor.js @@ -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); } diff --git a/js-plugins/drone/drone.js b/js-plugins/drone/drone.js index 7a3d416..978701e 100644 --- a/js-plugins/drone/drone.js +++ b/js-plugins/drone/drone.js @@ -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(); diff --git a/js-plugins/drone/fort.js b/js-plugins/drone/fort.js index 6b05545..15dab6f 100644 --- a/js-plugins/drone/fort.js +++ b/js-plugins/drone/fort.js @@ -1,4 +1,4 @@ -load($SCRIPT_DIR + "/drone.js"); +load(__folder + "drone.js"); // // constructs a medieval fort // diff --git a/js-plugins/drone/temple.js b/js-plugins/drone/temple.js index 4e209ea..e121e35 100644 --- a/js-plugins/drone/temple.js +++ b/js-plugins/drone/temple.js @@ -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'); -}); \ No newline at end of file +});