-
Notifications
You must be signed in to change notification settings - Fork 0
/
grabber.lua
47 lines (42 loc) · 1.46 KB
/
grabber.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
-- This program is going to take whatever item is in the first slot of the turtle and then look for it in the attached storage and then suck it out.
-- This means that you will need atleast one of the wanted item in the first slot of the turtle for it to grab them.
chestdirection = 'front'
chest = peripheral.wrap(chestdirection)
-- this function will determine the wanted item from the inventory and then print it to the screen
function finditem()
pork = turtle.getItemDetail(1)
--term.clear()
term.setCursorPos(1,1)
print("Grabbing",pork.name,"From Inventory")
end
-- this is just a sample function to that was used for reference, can be safley ignored
--[[
function test()
for slot, item in pairs(chest.list()) do
print(("%d x %s in slot %d"):format(item.count, item.name, slot))
end
end
]]
--This function is where the magic actually happens. it does the searching of the inventory table and then pulls the releavent item out.
function itempuller()
while true do
term.setCursorPos(1,4)
for slot, item in pairs(chest.list()) do
--print(item.name)
--error()
if item.name == pork.name then
term.clearLine()
print("Found", item.name,", Grabbing")
turtle.select(1)
turtle.suck()
else
term.clearLine()
print("Found ", item.name," Ignoring")
end
end
end
end
--Main Function Execution
term.clear()
finditem()
itempuller()