-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshulker-loader.lua
69 lines (65 loc) · 1.69 KB
/
shulker-loader.lua
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
local speaker = peripheral.find("speaker")
local chest = "minecraft:barrel_1143"
local name = peripheral.call("bottom", "getNameLocal")
local canRetrieve = false
local function render()
local m = peripheral.wrap("front")
if canRetrieve then
m.setTextScale(0.5)
m.setBackgroundColor(colors.white)
m.clear()
m.setCursorPos(3, 4)
m.setTextColor(colors.gray)
m.write("Right-click")
m.setCursorPos(3, 5)
m.write("to retrieve")
m.setCursorPos(3, 6)
m.write("shulker box")
else
m.setTextScale(0.5)
m.setBackgroundColor(colors.black)
m.clear()
end
end
local debounce = false
parallel.waitForAll(function()
while true do
local list = peripheral.call(chest, "list")
if debounce then sleep(5) end
if #list == 0 then
canRetrieve = false
turtle.suckUp()
if turtle.getItemCount(1) > 0 then
local data = turtle.getItemDetail(1)
if data.name:match("shulker_box") then
speaker.playSound("minecraft:entity.item.pickup", 1, 1)
canRetrieve = true
peripheral.call(chest, "pullItems", name, 1)
else
speaker.playSound("minecraft:entity.villager.no", 1, 1)
turtle.dropUp()
sleep(5)
end
end
else
canRetrieve = true
end
render()
sleep(1)
end
end, function()
while true do
local _, side = os.pullEvent("monitor_touch")
if side == "front" then
print("Retrieve")
peripheral.call(chest, "pushItems", name, 1, 1, 1)
turtle.dropUp()
speaker.playSound("minecraft:entity.item.pickup", 1, 1)
debounce = true
canRetrieve = false
render()
sleep(3)
debounce = false
end
end
end)