Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("turtleManualOneTrip.lua")
- --start with pick in left and geoscanner in right of turtle, and modem in first slot
- function scan()
- scanner = peripheral.wrap("right")
- if scanner.cost(15) > scanner.getFuelLevel() then
- print("Not Enough Fuel")
- print("Cost: " .. scanner.cost(15))
- print("Fuel Level: " .. scanner.getFuelLevel() .. "/" .. scanner.getMaxFuelLevel())
- os.exit(1)
- end
- turtle.equipRight()
- rednet.open("right")
- cx, cy, cz = gps.locate()
- if cx == nil and cy == nil and cz == nil then
- print("GPS Error")
- os.exit(1)
- end
- turtle.equipRight()
- if not item and choice == 2 then
- print("No Name Inputted")
- os.exit(1)
- end
- return scanner.scan(15)
- end
- function findItemSlot(itemName)
- for slot = 1, 16 do
- local itemDetail = turtle.getItemDetail(slot)
- if itemDetail and itemDetail.name == itemName then
- return slot
- end
- end
- return nil
- end
- function splitPairs(pairsArray)
- local keys = {}
- local values = {}
- for _, pair in ipairs(pairsArray) do
- table.insert(keys, pair[1])
- table.insert(values, pair[2])
- end
- return keys, values
- end
- function dropUnwantedItems(allowedItems)
- table.insert(allowedItems, "computercraft:wireless_modem_normal")
- for slot = 1, 16 do
- local itemDetail = turtle.getItemDetail(slot)
- if itemDetail then
- local isAllowed = false
- -- Check if the item is in the allowed list
- for _, allowedItem in ipairs(allowedItems) do
- if itemDetail.name == allowedItem then
- isAllowed = true
- break
- end
- end
- -- Drop the item if it's not allowed
- if not isAllowed then
- turtle.select(slot)
- turtle.drop()
- print("Dropped unwanted item: " .. itemDetail.name)
- end
- end
- end
- end
- function geoMineItem(item)
- blocks = scan()
- if blocks ~= nil then
- for _, block in pairs(blocks) do
- if block.name == item then
- x = cx + block.x
- y = cy + (block.y + 1)
- z = cz + block.z
- turtleManualOneTrip.goToCordsMine(x, y, z)
- end
- end
- turtleManualOneTrip.goToCordsMine(cx, cy, cz)
- else
- print("Couldnt Scan")
- end
- end
- function geoMineList(itemlist)
- itemlist, matlist = splitPairs(itemlist)
- found = false
- if itemlist ~= nil then
- blocks = scan()
- else
- print("Itemlist no found")
- os.exit(1)
- end
- if blocks ~= nil and itemlist ~= nil then
- for _, block in pairs(blocks) do
- for _, item in pairs(itemlist) do
- if block.name == item then
- x = cx + block.x
- y = cy + (block.y + 1)
- z = cz + block.z
- slot = findItemSlot("computercraft:wireless_modem_normal")
- if slot ~= nil then
- turtle.select(slot)
- end
- turtleManualOneTrip.goToCordsMine(x, y, z)
- dropUnwantedItems(matlist)
- found = true
- end
- end
- end
- if found then
- dropUnwantedItems(matlist)
- slot = findItemSlot("computercraft:wireless_modem_normal")
- if slot ~= nil then
- turtle.select(slot)
- end
- turtleManualOneTrip.goToCordsMine(cx, cy, cz)
- dropUnwantedItems(matlist)
- turtle.digUp()
- turtle.up()
- end
- elseif blocks == nil then
- print("Couldnt Scan")
- elseif itemlist == nil then
- print("Itemlist no found")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment