How it is possible to set the orientation of a piston?

639 views
Skip to first unread message

tjh

unread,
Sep 16, 2016, 3:41:50 PM9/16/16
to ScriptCraft - Scripting Minecraft
With scriptcraft 3.2 and spigot 1.9 using the .box() command  a sticky piston is always placed with the piston facing downwards.

How can the orientation be influenced?

tjh

unread,
Sep 16, 2016, 3:57:47 PM9/16/16
to ScriptCraft - Scripting Minecraft
Is it possible to use the undocumented setBlock command:

this
.setBlock(blocks.bed, bedDirections[this.dir], 0,0,0, false);

and using the block data:
0x0 facing down
0x1 facing up
0x2 facing north
0x3 facing south
0x4 facing west
0x5 facing east

https://github.com/walterhiggins/ScriptCraft/blob/c036e38f370bb51af99805d0693d6c2d83ca6a79/src/main/js/modules/drone/index.js

https://hub.spigotmc.org/javadocs/spigot/

setTypeIdAndData - deprecated



Anthony Wood

unread,
Oct 30, 2016, 5:59:11 AM10/30/16
to ScriptCraft - Scripting Minecraft
Did you find an answer to this?  I'm struggling too. Trying to script piston doors is a bit tricky without this...

Captain Starbuck

unread,
Oct 30, 2016, 6:40:37 AM10/30/16
to ScriptCraft - Scripting Minecraft
Message has been deleted

Woody

unread,
Oct 30, 2016, 8:41:12 AM10/30/16
to ScriptCraft - Scripting Minecraft
Thanks, that got me over the line. Working example:

// Like drone.box , but takes properties for setblock as second param
function boxprop(block, prop, x, y, z) {
if (typeof x == 'undefined') {
x = 1;
}
if (typeof y == 'undefined') {
y = 1;
}
if (typeof z == 'undefined') {
z = 1;
}
for ( var i = 0; i < x; i++ ) {
this.right(i);
for ( var j = 0; j < y ; j++ ) {
this.up(j);
for ( var k = 0; k < z ; k++ ) {
this.fwd(k);
this.setBlock(block,prop,0,0,0,false);
this.back(k);
}
this.down(j);
}
this.left(i);
}
}
Drone.extend(boxprop);

// have the pistons face the drone if prop is pistonDirections[this.dir], like in regular minecraft
var pistonDirections = {
  0:4, // east
  1:2, // south
  2:5, // west
  3:3  // north
};

function hiddendoor ( wall, floor ) {
if (typeof wall == 'undefined' ) {
wall = blocks.stone;
}
if (typeof floor == 'undefined' ) {
wall = blocks.grass;
}

this
.up(1).fwd(3)
.boxprop(blocks.sticky_piston,pistonDirections[this.dir],2,2,1);
this
.turn(1).fwd(3)
.boxprop(blocks.sticky_piston,pistonDirections[this.dir],2,2,1)
.turn(2).left(1).fwd(5)
.boxprop(blocks.sticky_piston,pistonDirections[this.dir],2,2,1);
}
Drone.extend(hiddendoor);


Reply all
Reply to author
Forward
0 new messages