lift.lua
43 lines · 830 B
Update: 4SzF1Sab
Copy & run
wget https://perlytiara.github.io/turtles.tips/raw/programs/Michael-Reeves808/lift.lua
| 1 | -- Update: 4SzF1Sab |
| 2 | -- pastebin get 4SzF1Sab update |
| 3 | -- lift up update |
| 4 | |
| 5 | |
| 6 | local args = {...} |
| 7 | local SLOT_COUNT = 16 |
| 8 | |
| 9 | |
| 10 | function dropItems(direction) |
| 11 | if(direction == 'forward') then |
| 12 | turtle.drop() |
| 13 | elseif(direction == 'up') then |
| 14 | turtle.dropUp() |
| 15 | elseif(direction == 'down') then |
| 16 | turtle.dropDown() |
| 17 | elseif(direction == nil) then |
| 18 | turtle.drop() |
| 19 | end |
| 20 | |
| 21 | end |
| 22 | |
| 23 | function getFirstItemIndex() |
| 24 | for i = 1, SLOT_COUNT, 1 do |
| 25 | turtle.select(i) |
| 26 | if turtle.getItemDetail() ~= nil then |
| 27 | return i |
| 28 | end |
| 29 | end |
| 30 | |
| 31 | return nil |
| 32 | end |
| 33 | |
| 34 | print('Lift Starting in mode: ' .. args[1]) |
| 35 | while (true) do |
| 36 | os.pullEvent('turtle_inventory') |
| 37 | i = getFirstItemIndex() |
| 38 | if (i ~= nil) then |
| 39 | turtle.select(i) |
| 40 | dropItems(args[1]) |
| 41 | turtle.suckDown() |
| 42 | end |
| 43 | end |