-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkyChestFinder.lua
More file actions
111 lines (90 loc) · 2.49 KB
/
SkyChestFinder.lua
File metadata and controls
111 lines (90 loc) · 2.49 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
-- SkyChest search program by Caio "Jabulba" Jabulka 2015
-- Turtle type: Mining Turtle
-- Purpose: Use this program to find hidden meteores from Applied Energistics 2.
-- The turtle will dig down until it finds the chest or bedrock
-- if the chest is found chest the turtle will empty it, pick it up and retur to the surface
-- if bedrock is found the turtle returns to the surface, if it broke skystone it will print a warning
-- Licensed MIT
local skyChestId = "appliedenergistics2:sky_stone_chest"
local skyStoneId = "appliedenergistics2:sky_stone_block"
local bedrockId = "minecraft:bedrock"
local movesDone = 0
local skyChestFound = false
local skyStoneFound = false
local function placeFloor(slot)
slot = slot or 1
if slot > 16 then
return true
end
if turtle.getItemCount(slot) > 0 then
turtle.select(slot)
if not turtle.placeDown() then
placeFloor(slot + 1)
end
end
return true
end
local function digMove(direction, attempts)
direction = direction or "forward"
attempts = attempts or 1
if direction == "d" or direction == "down" then
local hasBlock, blockData = turtle.inspectDown()
if hasBlock and blockData.name == bedrockId then
skyChestFound = true
return
end
turtle.digDown()
if not turtle.down() then
turtle.attackDown()
digMove("d", attempts)
end
movesDone = movesDone + 1
elseif direction == "u" or direction == "up" then
turtle.digUp()
if not turtle.up() then
turtle.attackUp()
digMove("u", attempts)
end
movesDone = movesDone - 1
end
return true
end
miss = 0
while not skyChestFound do
local hasBlock, blockData = turtle.inspectDown()
local hasBlockInFront, frontBlockData = turtle.inspect()
if hasBlock and blockData.name == skyChestId then
while turtle.suckDown() do
print("Picking item from sky chest")
end
turtle.digDown()
skyChestFound = true
elseif hasBlockInFront and frontBlockData.name == skyChestId then
while turtle.suck() do
print("Picking item from sky chest")
end
turtle.dig()
skyChestFound = true
elseif hasBlock and blockData.name == skyStoneId or hasBlockInFront and frontBlockData.name == skyStoneId then
print("Sky Stone!")
skyStoneFound = true
miss = 0
if frontBlockData.name == skyStoneId then
turtle.dig()
end
digMove("down")
else
if skyStoneFound and miss > 4 then
print("To many misses, returning!")
break
end
miss = miss + 1
digMove("down")
end
end
while movesDone > 0 do
digMove("up")
if movesDone < 5 then
placeFloor()
end
end