fix issue #97
This commit is contained in:
parent
4f390374ef
commit
5263ad1b5d
7 changed files with 47 additions and 28 deletions
|
@ -12,7 +12,8 @@ plugin("alias", {
|
||||||
set: function(player, alias, commands){
|
set: function(player, alias, commands){
|
||||||
var aliases = this.store.players;
|
var aliases = this.store.players;
|
||||||
var name = player.name;
|
var name = player.name;
|
||||||
aliases[name] = aliases[name] || {};
|
if (typeof aliases[name] == "undefined")
|
||||||
|
aliases[name] = {};
|
||||||
aliases[name][alias] = commands;
|
aliases[name][alias] = commands;
|
||||||
},
|
},
|
||||||
remove: function(player, alias){
|
remove: function(player, alias){
|
||||||
|
@ -29,7 +30,8 @@ plugin("alias", {
|
||||||
}
|
}
|
||||||
},true);
|
},true);
|
||||||
|
|
||||||
alias.store.players = alias.store.players || {};
|
if (typeof alias.store.players == "undefined")
|
||||||
|
alias.store.players = {};
|
||||||
|
|
||||||
command("alias",function(params){
|
command("alias",function(params){
|
||||||
/*
|
/*
|
||||||
|
@ -67,7 +69,7 @@ command("alias",function(params){
|
||||||
for (var i = 0;i < commands.length; i++){
|
for (var i = 0;i < commands.length; i++){
|
||||||
// fill in template
|
// fill in template
|
||||||
var cmd = commands[i];
|
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);
|
self.performCommand(cmd);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -9,10 +9,14 @@
|
||||||
*/
|
*/
|
||||||
Drone.extend("chessboard", function(whiteBlock, blackBlock, width, depth) {
|
Drone.extend("chessboard", function(whiteBlock, blackBlock, width, depth) {
|
||||||
this.chkpt('chessboard-start');
|
this.chkpt('chessboard-start');
|
||||||
width = width || 8;
|
if (typeof whiteBlock == "undefined")
|
||||||
depth = depth || width;
|
whiteBlock = blocks.wool.white;
|
||||||
blackBlock = blackBlock || blocks.wool.black;
|
if (typeof blackBlock == "undefined")
|
||||||
whiteBlock = whiteBlock || blocks.wool.white;
|
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 i = 0; i < width; ++i) {
|
||||||
for(var j = 0; j < depth; ++j) {
|
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);
|
this.move('chessboard-start').fwd(i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.move('chessboard-start');
|
return this.move('chessboard-start');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
Drone.extend('skyscraper',function(floors){
|
Drone.extend('skyscraper',function(floors){
|
||||||
floors = floors || 10;
|
|
||||||
|
if (typeof floors == "undefined")
|
||||||
|
floors = 10;
|
||||||
this.chkpt('skyscraper');
|
this.chkpt('skyscraper');
|
||||||
for (var i = 0;i < floors; i++)
|
for (var i = 0;i < floors; i++)
|
||||||
{
|
{
|
||||||
this.box(blocks.iron,20,1,20)
|
this
|
||||||
|
.box(blocks.iron,20,1,20)
|
||||||
.up()
|
.up()
|
||||||
.box0(blocks.glass_pane,20,3,20);
|
.box0(blocks.glass_pane,20,3,20)
|
||||||
this.up(3);
|
.up(3);
|
||||||
}
|
}
|
||||||
return this.move('skyscraper');
|
return this.move('skyscraper');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1213,10 +1213,8 @@ Another example: This statement creates a row of trees 2 by 3 ...
|
||||||
var ddF_y = -2 * radius;
|
var ddF_y = -2 * radius;
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = radius;
|
var y = radius;
|
||||||
quadrants = quadrants || {topleft: true,
|
var defaultQuadrants = {topleft: true, topright: true, bottomleft: true, bottomright: true};
|
||||||
topright: true,
|
quadrants = quadrants?quadrants:defaultQuadrants;
|
||||||
bottomleft: true,
|
|
||||||
bottomright: true};
|
|
||||||
/*
|
/*
|
||||||
II | I
|
II | I
|
||||||
------------
|
------------
|
||||||
|
@ -1284,16 +1282,16 @@ Another example: This statement creates a row of trees 2 by 3 ...
|
||||||
var _arc2 = function( params ) {
|
var _arc2 = function( params ) {
|
||||||
|
|
||||||
var drone = params.drone;
|
var drone = params.drone;
|
||||||
var orientation = params.orientation || "horizontal";
|
var orientation = params.orientation?params.orientation:"horizontal";
|
||||||
var quadrants = params.quadrants || {
|
var quadrants = params.quadrants?params.quadrants:{
|
||||||
topright:1,
|
topright:1,
|
||||||
topleft:2,
|
topleft:2,
|
||||||
bottomleft:3,
|
bottomleft:3,
|
||||||
bottomright:4
|
bottomright:4
|
||||||
};
|
};
|
||||||
var stack = params.stack || 1;
|
var stack = params.stack?params.stack:1;
|
||||||
var radius = params.radius;
|
var radius = params.radius;
|
||||||
var strokeWidth = params.strokeWidth || 1;
|
var strokeWidth = params.strokeWidth?params.strokeWidth:1;
|
||||||
drone.chkpt('arc2');
|
drone.chkpt('arc2');
|
||||||
var x0, y0, gotoxy,setPixel;
|
var x0, y0, gotoxy,setPixel;
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,10 @@ plugin("homes", {
|
||||||
if (online[i].name != player.name)
|
if (online[i].name != player.name)
|
||||||
result.push(online[i].name);
|
result.push(online[i].name);
|
||||||
}else{
|
}else{
|
||||||
result = this.store.invites[player.name] || [];
|
if (this.store.invites[player.name])
|
||||||
|
result = this.store.invites[player.name];
|
||||||
|
else
|
||||||
|
result = [];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -119,7 +122,9 @@ plugin("homes", {
|
||||||
invite: function(host, guest){
|
invite: function(host, guest){
|
||||||
host = utils.getPlayerObject(host);
|
host = utils.getPlayerObject(host);
|
||||||
guest = utils.getPlayerObject(guest);
|
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);
|
invitations.push(guest.name);
|
||||||
this.store.invites[host.name] = invitations;
|
this.store.invites[host.name] = invitations;
|
||||||
guest.sendMessage(host.name + " has invited you to their home.");
|
guest.sendMessage(host.name + " has invited you to their home.");
|
||||||
|
@ -275,7 +280,11 @@ plugin("homes", {
|
||||||
/*
|
/*
|
||||||
initialize the store
|
initialize the store
|
||||||
*/
|
*/
|
||||||
homes.store.houses = homes.store.houses || {};
|
if (typeof homes.store.houses == "undefined")
|
||||||
homes.store.openHouses = homes.store.openHouses || {};
|
homes.store.houses = {};
|
||||||
homes.store.invites = homes.store.invites || {};
|
if (typeof homes.store.openHouses == "undefined")
|
||||||
|
homes.store.openHouses = {};
|
||||||
|
if (typeof homes.store.invites == "undefined")
|
||||||
|
homes.store.invites = {};
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -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)
|
http.request = function( request, callback)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,11 @@ http.request = function( request, callback)
|
||||||
requestMethod = "GET";
|
requestMethod = "GET";
|
||||||
}else{
|
}else{
|
||||||
paramsAsString = paramsToString(request.params);
|
paramsAsString = paramsToString(request.params);
|
||||||
requestMethod = request.method || "GET";
|
if (request.method)
|
||||||
|
requestMethod = request.method
|
||||||
|
else
|
||||||
|
requestMethod = "GET";
|
||||||
|
|
||||||
if (requestMethod == "GET" && request.params){
|
if (requestMethod == "GET" && request.params){
|
||||||
// append each parameter to the URL
|
// append each parameter to the URL
|
||||||
url = request.url + "?" + paramsAsString;
|
url = request.url + "?" + paramsAsString;
|
||||||
|
|
|
@ -9,7 +9,7 @@ Miscellaneous utility functions and classes to help with programming.
|
||||||
player or `self` if no name is provided.
|
player or `self` if no name is provided.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
var utils = utils || {
|
var utils = utils ? utils : {
|
||||||
locationToString: function(location){
|
locationToString: function(location){
|
||||||
return JSON.stringify([""+location.world.name,location.x, location.y, location.z]);
|
return JSON.stringify([""+location.world.name,location.x, location.y, location.z]);
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue