var ArenaMaterial; var FenceHeight; var FillMaterial; var PlatformSize; var PlatformWidth; var center_drone; var d; var direction; var distance; var fill; var fill_material; var height; var material; var p_height; var p_material; var size; function ArenaWithFence(FenceHeight, PlatformSize, PlatformWidth, ArenaMaterial, FillMaterial) { size = PlatformSize; p_height = PlatformWidth; material = ArenaMaterial; fill_material = FillMaterial; height = FenceHeight; Platform(material, false); d.up(PlatformWidth); d.right(1); d.back(1); Fence(); d.left(1); d.fwd(1); Platform(fill_material, true); } // Size is the size of the platform that the fence is covering. function Fence() { var repeat_end = size + 1; for (var count2 = 0; count2 < repeat_end; count2++) { for (var count = 0; count < height; count++) { d.box(material); d.up(1); } d.fwd(1); d.down(height); } var repeat_end2 = size + 1; for (var count4 = 0; count4 < repeat_end2; count4++) { for (var count3 = 0; count3 < height; count3++) { d.box(material); d.up(1); } d.left(1); d.down(height); } var repeat_end3 = size + 1; for (var count6 = 0; count6 < repeat_end3; count6++) { for (var count5 = 0; count5 < height; count5++) { d.box(material); d.up(1); } d.back(1); d.down(height); } var repeat_end4 = size + 1; for (var count8 = 0; count8 < repeat_end4; count8++) { for (var count7 = 0; count7 < height; count7++) { d.box(material); d.up(1); } d.right(1); d.down(height); } } function GetArenaCenter() { return center_drone.getLocation(); } function Platform(p_material, fill) { for (var count11 = 0; count11 < size; count11++) { for (var count10 = 0; count10 < size; count10++) { if (fill) { d.box(p_material); d.up(1); d.fwd(1); d.down(1); } else { for (var count9 = 0; count9 < p_height; count9++) { d.box(p_material); d.up(1); } d.fwd(1); d.down(p_height); } } d.back(size); d.left(1); } d.right(size); } function SetArenaCenter() { center_drone.setLocation((d.getLocation())); center_drone.up((height + p_height)); center_drone.left((size / 2)); center_drone.fwd((size / 2)); d.box((Material.MELON_BLOCK)); d.up(1); } function move_drone(direction, distance) { if (direction == 'up') { d.up(distance); } if (direction == 'down') { d.down(distance); } if (direction == 'left') { d.left(distance); } if (direction == 'right') { d.right(distance); } if (direction == 'forward') { d.fwd(distance); } if (direction == 'backward') { d.back(distance); } } function init() { d = (new Drone(me, me.location)); center_drone = (new Drone(me, me.location)); }