SHOW:
|
|
- or go back to the newest paste.
1 | os.loadAPI("turtleManualOneTrip.lua") | |
2 | --start with pick in left and geoscanner in right of turtle, and modem in first slot | |
3 | ||
4 | - | function getSearchItem() |
4 | + | function scan() |
5 | - | print("Please Insert Item to Mine in Second Slot") |
5 | + | scanner = peripheral.wrap("right") |
6 | - | print("Then Press Enter") |
6 | + | if scanner.cost(15) > scanner.getFuelLevel() then |
7 | - | read() |
7 | + | print("Not Enough Fuel") |
8 | - | desireditem = turtle.getItemDetail(2) |
8 | + | print("Cost: " .. scanner.cost(15)) |
9 | - | return desireditem.name |
9 | + | print("Fuel Level: " .. scanner.getFuelLevel() .. "/" .. scanner.getMaxFuelLevel()) |
10 | os.exit(1) | |
11 | end | |
12 | - | scanner = peripheral.wrap("right") |
12 | + | |
13 | - | if scanner.cost(15) > scanner.getFuelLevel() then |
13 | + | turtle.equipRight() |
14 | - | print("Not Enough Fuel") |
14 | + | rednet.open("right") |
15 | - | print("Cost: " .. scanner.cost(15)) |
15 | + | cx, cy, cz = gps.locate() |
16 | - | print("Fuel Level: " .. scanner.getFuelLevel() .. "/" .. scanner.getMaxFuelLevel()) |
16 | + | if cx == nil and cy == nil and cz == nil then |
17 | - | os.exit(1) |
17 | + | print("GPS Error") |
18 | os.exit(1) | |
19 | end | |
20 | - | turtle.equipRight() |
20 | + | turtle.equipRight() |
21 | - | rednet.open("right") |
21 | + | |
22 | - | cx, cy, cz = gps.locate() |
22 | + | if not item and choice == 2 then |
23 | - | if cx == nil and cy == nil and cz == nil then |
23 | + | print("No Name Inputted") |
24 | - | print("GPS Error") |
24 | + | os.exit(1) |
25 | - | os.exit(1) |
25 | + | |
26 | ||
27 | - | turtle.equipRight() |
27 | + | return scanner.scan(15) |
28 | end | |
29 | - | print("Item or Name? (1 or 2)") |
29 | + | |
30 | - | choice = tonumber(read()) |
30 | + | function geoMineItem(item) |
31 | - | if choice ~= nil and choice == 1 then |
31 | + | blocks = scan() |
32 | - | item = getSearchItem() |
32 | + | if blocks ~= nil then |
33 | - | elseif choice ~= nil and choice == 2 then |
33 | + | for _, block in pairs(blocks) do |
34 | - | print("Please input item in game name (with library included)") |
34 | + | if block.name == item then |
35 | - | item = read() |
35 | + | x = cx + block.x |
36 | y = cy + (block.y + 1) | |
37 | z = cz + block.z | |
38 | - | if not item and choice == 1 then |
38 | + | turtleManualOneTrip.goToCordsMine(x, y, z) |
39 | - | print("No Item Inserted") |
39 | + | end |
40 | - | os.exit(1) |
40 | + | |
41 | - | elseif not item and choice == 2 then |
41 | + | turtleManualOneTrip.goToCordsMine(cx, cy, cz) |
42 | - | print("No Name Inputted") |
42 | + | else |
43 | - | os.exit(1) |
43 | + | print("Couldnt Scan") |
44 | end | |
45 | end | |
46 | - | blocks = scanner.scan(15) |
46 | + | |
47 | function geoMineList(itemlist) | |
48 | if itemlist ~= nil then | |
49 | - | if blocks ~= nil then |
49 | + | blocks = scan() |
50 | - | for _, block in pairs(blocks) do |
50 | + | else |
51 | - | if block.name == item then |
51 | + | print("Itemlist no found") |
52 | - | x = cx + block.x |
52 | + | os.exit(1) |
53 | - | y = cy + (block.y + 1) |
53 | + | |
54 | - | z = cz + block.z |
54 | + | if blocks ~= nil and itemlist ~= nil then |
55 | - | turtleManualOneTrip.goToCordsMine(x, y, z) |
55 | + | for _, block in pairs(blocks) do |
56 | for _, item in pairs(itemlist) do | |
57 | if block.name == item then | |
58 | - | turtleManualOneTrip.goToCordsMine(cx, cy, cz) |
58 | + | x = cx + block.x |
59 | - | else |
59 | + | y = cy + (block.y + 1) |
60 | - | print("Couldnt Scan") |
60 | + | z = cz + block.z |
61 | turtleManualOneTrip.goToCordsMine(x, y, z) | |
62 | end | |
63 | end | |
64 | end | |
65 | turtleManualOneTrip.goToCordsMine(cx, cy, cz) | |
66 | elseif blocks == nil then | |
67 | print("Couldnt Scan") | |
68 | elseif itemlist == nil then | |
69 | print("Itemlist no found") | |
70 | end | |
71 | end |