-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeacon.lua
More file actions
73 lines (59 loc) · 1.45 KB
/
beacon.lua
File metadata and controls
73 lines (59 loc) · 1.45 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
-- Remote controlled player beacon activation by Roachy
local side = 'front'
local slot = 1
local function tryDigDown()
while turtle.detectDown() do
if turtle.digDown() then
sleep(0.5)
else
return false
end
end
return true
end
local function getSignal()
return redstone.getInput(side)
end
turtle.select(slot)
while true do
signal = getSignal()
--print('signal = ' .. tostring(signal))
itemCount = turtle.getItemCount(slot)
--print('itemCount = ' .. tostring(itemCount))
time = os.time()
fTime = '(' .. textutils.formatTime(time, true) .. ')'
if(signal) then
print(fTime .. ' Signal detected.')
if(itemCount > 0) then
print('- Item detected in slot.')
if(not turtle.detectDown()) then
print('- Block not detected below.')
print('- Placing item...')
turtle.placeDown()
else
print('- Block detected below!')
print('- There must be an extra block/item!')
end
else
print('- Item not detected in slot.')
print('- Skipping placing item.')
end
else
print(fTime .. ' Signal not detected.')
if(itemCount < 1) then
print('- Item not detected in slot.')
if(turtle.detectDown()) then
print('- Block detected below.')
print('- Digging block...')
turtle.digDown()
else
print('- No block detected below!')
print('- Block/item must be missing!')
end
else
print('- Item already detected in slot.')
print('- Skipping digging block.')
end
end
sleep(5)
end