-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube_layered.lua
More file actions
92 lines (81 loc) · 1.65 KB
/
cube_layered.lua
File metadata and controls
92 lines (81 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--robot = require("robot")
robot = require("testing")
movement = require("movement")
arg = {...}
blockIndex = 0
function orientate()
while robot.detect() do
robot.turnRight()
end
robot.forward()
robot.turnLeft()
end
function lineUpRow()
movement.moveLeft(2)
robot.turnRight()
end
function place(cube)
blockIndex = blockIndex + 1
if cube[blockIndex] == nil then
robot.select(cube.default)
else
robot.select(cube[blockIndex])
end
robot.place()
end
function placeRow(cube)
for i=1,2 do
place(cube)
movement.moveRight(1)
robot.turnLeft()
end
place(cube)
print("Row Done")
end
function placeLayer(cube)
for i=1,2 do
placeRow(cube)
robot.back()
lineUpRow()
end
placeRow(cube)
print("Layer Done")
end
function drop(cube)
robot.back()
robot.select(cube["drop"])
robot.drop()
robot.forward()
end
function placeCube(cube, n)
orientate()
for j=1,n do
for i=1,3 do
movement.moveForward(2)
placeLayer(cube)
lineUpRow()
if i ~= 3 then
robot.up()
end
end
for i=1,2 do
robot.down()
end
drop(cube)
print("Completed " .. cubeName)
end
end
cubes = {
["enderpearl"]={["default"]=1, ["drop"]=3; [14]=2},
}
cubeName = arg[1]
n = arg[2] or 1
if cubeName == nil then
print("Enter cube to build")
elseif cubes[cubeName] == nil then
print('Unknown cube "' .. cubeName .. '"')
elseif not tonumber(n) then
print(n .. " is not an integer")
else
placeCube(cubes[arg[1]], n)
end