Implement getBlock on drone.
parent
d2354bea7b
commit
b595ba975a
|
@ -553,8 +553,10 @@ Drone.prototype.times = function( numTimes, commands ) {
|
|||
|
||||
|
||||
Drone.prototype.getBlock = function(){
|
||||
return undefined; //this.world.getBlockAt(this.x,this.y,this.z);
|
||||
var bl = get_node(this.x,this.y,this.z);
|
||||
return new smBlock(bl.typeId, bl.nodeName);
|
||||
};
|
||||
|
||||
Drone.prototype.setBlock = function(blockType, data, ow, oh, od, update){
|
||||
if (typeof ow == 'undefined')
|
||||
ow = 0;
|
||||
|
@ -706,7 +708,7 @@ Drone.prototype.then = function( next ){
|
|||
thisNext();
|
||||
this.move(chkNow);
|
||||
}
|
||||
getQueue(this).push( wrapperFn.bind(this) );
|
||||
getQueue(this).push( wrapperFn.bind(this) );
|
||||
return this;
|
||||
};
|
||||
Drone.prototype.cuboid = function( block, w, h, d, immediate ) {
|
||||
|
|
|
@ -13,6 +13,13 @@ Duktape.modSearch = function (id)
|
|||
throw new Error('module not found: ' + id);
|
||||
}
|
||||
|
||||
function smBlock(typeId, nodeName)
|
||||
{
|
||||
this.typeId = typeId;
|
||||
this.nodeName = nodeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
var global = this;
|
||||
var blocks = require("blocks");
|
||||
var Drone = require("drone");
|
||||
|
|
10
scriptmine.c
10
scriptmine.c
|
@ -15,6 +15,10 @@ const char *blockIDToNodeName[][2] =
|
|||
{"4", "default:cobble"},
|
||||
{"5", "default:wood"},
|
||||
{"5:1", "default:pine_wood"},
|
||||
{"8", "default:water_source"},
|
||||
{"9", "default:water_source"},
|
||||
{"10", "default:lava_source"},
|
||||
{"11", "default:lava_source"},
|
||||
{"12", "default:sand"},
|
||||
{"13", "default:gravel"},
|
||||
{"14", "default:stone_with_gold"},
|
||||
|
@ -137,7 +141,7 @@ duk_ret_t get_node(duk_context *ctx)
|
|||
lua_setfield(Lg, -2, "y");
|
||||
lua_pushnumber(Lg, z);
|
||||
lua_setfield(Lg, -2, "z");
|
||||
lua_call(Lg, 1, 0);
|
||||
lua_call(Lg, 1, 1);
|
||||
lua_getfield(Lg, -1, "name");
|
||||
const char *node_name = lua_tostring(Lg, -1);
|
||||
const char *blockID = node_name_to_blockID(node_name);
|
||||
|
@ -172,7 +176,7 @@ duk_ret_t place_node(duk_context *ctx)
|
|||
lua_pushstring(Lg, nodeName);
|
||||
lua_setfield(Lg, -2, "name");
|
||||
lua_call(Lg, 2, 0);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
duk_ret_t set_node(duk_context *ctx)
|
||||
|
@ -196,7 +200,7 @@ duk_ret_t set_node(duk_context *ctx)
|
|||
lua_pushstring(Lg, nodeName);
|
||||
lua_setfield(Lg, -2, "name");
|
||||
lua_call(Lg, 2, 0);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
duk_ret_t get_player_location(duk_context *ctx)
|
||||
|
|
Loading…
Reference in New Issue