This commit is contained in:
walterhiggins 2013-12-08 12:16:41 +00:00
parent 4f390374ef
commit 5263ad1b5d
7 changed files with 47 additions and 28 deletions

View file

@ -12,7 +12,8 @@ plugin("alias", {
set: function(player, alias, commands){
var aliases = this.store.players;
var name = player.name;
aliases[name] = aliases[name] || {};
if (typeof aliases[name] == "undefined")
aliases[name] = {};
aliases[name][alias] = commands;
},
remove: function(player, alias){
@ -29,7 +30,8 @@ plugin("alias", {
}
},true);
alias.store.players = alias.store.players || {};
if (typeof alias.store.players == "undefined")
alias.store.players = {};
command("alias",function(params){
/*
@ -67,7 +69,7 @@ command("alias",function(params){
for (var i = 0;i < commands.length; i++){
// fill in template
var cmd = commands[i];
cmd = cmd.replace(/{([0-9]*)}/g,function(dummy,index){ return params[index] || "";})
cmd = cmd.replace(/{([0-9]*)}/g,function(dummy,index){ return params[index] ? params[index] : "";})
self.performCommand(cmd);
}
return true;

View file

@ -9,10 +9,14 @@
*/
Drone.extend("chessboard", function(whiteBlock, blackBlock, width, depth) {
this.chkpt('chessboard-start');
width = width || 8;
depth = depth || width;
blackBlock = blackBlock || blocks.wool.black;
whiteBlock = whiteBlock || blocks.wool.white;
if (typeof whiteBlock == "undefined")
whiteBlock = blocks.wool.white;
if (typeof blackBlock == "undefined")
blackBlock = blocks.wool.black;
if (typeof width == "undefined")
width = 8;
if (typeof depth == "undefined")
depth = width;
for(var i = 0; i < width; ++i) {
for(var j = 0; j < depth; ++j) {
@ -25,6 +29,5 @@ Drone.extend("chessboard", function(whiteBlock, blackBlock, width, depth) {
}
this.move('chessboard-start').fwd(i+1);
}
return this.move('chessboard-start');
});

View file

@ -1,12 +1,15 @@
Drone.extend('skyscraper',function(floors){
floors = floors || 10;
if (typeof floors == "undefined")
floors = 10;
this.chkpt('skyscraper');
for (var i = 0;i < floors; i++)
{
this.box(blocks.iron,20,1,20)
this
.box(blocks.iron,20,1,20)
.up()
.box0(blocks.glass_pane,20,3,20);
this.up(3);
.box0(blocks.glass_pane,20,3,20)
.up(3);
}
return this.move('skyscraper');
});

View file

@ -1213,10 +1213,8 @@ Another example: This statement creates a row of trees 2 by 3 ...
var ddF_y = -2 * radius;
var x = 0;
var y = radius;
quadrants = quadrants || {topleft: true,
topright: true,
bottomleft: true,
bottomright: true};
var defaultQuadrants = {topleft: true, topright: true, bottomleft: true, bottomright: true};
quadrants = quadrants?quadrants:defaultQuadrants;
/*
II | I
------------
@ -1284,16 +1282,16 @@ Another example: This statement creates a row of trees 2 by 3 ...
var _arc2 = function( params ) {
var drone = params.drone;
var orientation = params.orientation || "horizontal";
var quadrants = params.quadrants || {
var orientation = params.orientation?params.orientation:"horizontal";
var quadrants = params.quadrants?params.quadrants:{
topright:1,
topleft:2,
bottomleft:3,
bottomright:4
};
var stack = params.stack || 1;
var stack = params.stack?params.stack:1;
var radius = params.radius;
var strokeWidth = params.strokeWidth || 1;
var strokeWidth = params.strokeWidth?params.strokeWidth:1;
drone.chkpt('arc2');
var x0, y0, gotoxy,setPixel;

View file

@ -109,7 +109,10 @@ plugin("homes", {
if (online[i].name != player.name)
result.push(online[i].name);
}else{
result = this.store.invites[player.name] || [];
if (this.store.invites[player.name])
result = this.store.invites[player.name];
else
result = [];
}
return result;
},
@ -119,7 +122,9 @@ plugin("homes", {
invite: function(host, guest){
host = utils.getPlayerObject(host);
guest = utils.getPlayerObject(guest);
var invitations = this.store.invites[host.name] || [];
var invitations = [];
if (this.store.invites[host.name])
invitations = this.store.invites[host.name];
invitations.push(guest.name);
this.store.invites[host.name] = invitations;
guest.sendMessage(host.name + " has invited you to their home.");
@ -275,7 +280,11 @@ plugin("homes", {
/*
initialize the store
*/
homes.store.houses = homes.store.houses || {};
homes.store.openHouses = homes.store.openHouses || {};
homes.store.invites = homes.store.invites || {};
if (typeof homes.store.houses == "undefined")
homes.store.houses = {};
if (typeof homes.store.openHouses == "undefined")
homes.store.openHouses = {};
if (typeof homes.store.invites == "undefined")
homes.store.invites = {};
}());

View file

@ -39,7 +39,7 @@ The following example illustrates how to use http.request to make a request to a
});
***/
var http = http || {};
var http = http ? http : {};
http.request = function( request, callback)
{
@ -65,7 +65,11 @@ http.request = function( request, callback)
requestMethod = "GET";
}else{
paramsAsString = paramsToString(request.params);
requestMethod = request.method || "GET";
if (request.method)
requestMethod = request.method
else
requestMethod = "GET";
if (requestMethod == "GET" && request.params){
// append each parameter to the URL
url = request.url + "?" + paramsAsString;

View file

@ -9,7 +9,7 @@ Miscellaneous utility functions and classes to help with programming.
player or `self` if no name is provided.
***/
var utils = utils || {
var utils = utils ? utils : {
locationToString: function(location){
return JSON.stringify([""+location.world.name,location.x, location.y, location.z]);
},