From de113db48c896aa36c18bc4ae1d58be6aef78207 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Sun, 16 Feb 2014 18:31:09 +0000 Subject: [PATCH] Adding new hangtorch() drone function. --- .../js/plugins/drone/contrib/hangtorch.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/js/plugins/drone/contrib/hangtorch.js diff --git a/src/main/js/plugins/drone/contrib/hangtorch.js b/src/main/js/plugins/drone/contrib/hangtorch.js new file mode 100644 index 0000000..6f4c011 --- /dev/null +++ b/src/main/js/plugins/drone/contrib/hangtorch.js @@ -0,0 +1,29 @@ +var Drone = require('../drone').Drone; +var Material = org.bukkit.Material; +function canHang(material){ + if (material.equals(Material.AIR) || + material.equals(Material.VINE) ) { + return true; + } else { + return false; + } +} +Drone.extend('hangtorch', function () { + var torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir]; + var moves = 0; + var block = this.world.getBlockAt(this.x, this.y, this.z); + + while ( !canHang(block.type) ){ + + moves++; + this.back(); + if (moves == 10){ + this.fwd(moves); + console.log('no air to hang torch'); + return; + } + block = this.world.getBlockAt(this.x, this.y, this.z); + } + this.box(torch); + this.fwd(moves); +});