Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("API") then
- shell.run("pastebin", "get", "EzkfU5ZM", "API")
- end
- shaka = require("API")
- shaka.connectModem()
- direction = nil
- compFound = false --- CHANGE THIS TO FALSE
- dropped = 0
- speaker = peripheral.find("speaker")
- -- speaker.playSound("entity.lightning_bolt.impact")
- local args = { ... }
- args = tonumber(args[1])
- local moveSetFileName = "newMoveSet"
- local function generateMoveSetFiles()
- local counter = 0
- local newFileName = nil
- if fs.exists(moveSetFileName) then
- while true do
- newFileName = moveSetFileName..counter
- if fs.exists(newFileName) then
- print(newFileName, "exists -", counter)
- counter = counter + 1
- else
- return newFileName, counter
- end
- end
- end
- end
- -- print(generateMoveSetFiles())
- local function findPocketComputer()
- id = nil --- change this to nil !!!!!!!!!!!!!!!!!!!!!!!!
- while not compFound do
- shaka.clearScreen()
- shaka.changeColors(colors.gray, colors.yellow)
- textutils.slowPrint("Searching for transmitter..\n")
- rednet.broadcast("anybody out there?", "transporterPing")
- local id, msg = rednet.receive("transporterAnswer", 0.1)
- if id then
- shaka.changeColors(colors.black, colors.green)
- textutils.slowPrint("Success..\n")
- print("Connected to PocketPC ID: "..id..".")
- term.setTextColor(colors.yellow)
- print("Ready to receive commands.")
- compFound = true
- break
- end
- end
- end
- local function leftTurn()
- turtle.turnLeft()
- if direction == "north" then
- direction = "west"
- elseif direction == "west" then
- direction = "south"
- elseif direction == "south" then
- direction = "east"
- elseif direction == "east" then
- direction = "north"
- end
- return true
- end
- function rightTurn()
- turtle.turnRight()
- if direction == "north" then
- direction = "east"
- elseif direction == "east" then
- direction = "south"
- elseif direction == "south" then
- direction = "west"
- elseif direction == "west" then
- direction = "north"
- end
- return true
- end
- local function findDirection()
- print("Finding direction..")
- shaka.turtleResetRedstone()
- local x, y, z = gps.locate()
- local leftTurns = 0
- local upLock = false
- local downLock = false
- local upCount = 0
- local downCount = 0
- --find spot to move forward
- if not turtle.forward() then
- repeat
- leftTurns = leftTurns + 1
- turtle.turnLeft()
- if leftTurns == 4 then
- if turtle.up() then
- upCount = upCount + 1
- else
- for i = 1, upCount do
- turtle.down()
- end
- upCount = 0
- upLock = true
- end
- if upLock then
- if turtle.down() then
- downCount = downCount + 1
- else
- downLock = true
- end
- end
- leftTurns = 0
- end
- if downLock then
- return false
- end
- until turtle.forward()
- end
- --determine direction
- local aNew, b, zNew = gps.locate()
- if zNew < z then
- direction = "north"
- elseif zNew > z then
- direction = "south"
- elseif aNew < x then
- direction = "west"
- elseif aNew > x then
- direction = "east"
- end
- --go back to original position
- repeat until turtle.back()
- for i = 1, leftTurns do
- rightTurn()
- end
- for i = 1, upCount do
- repeat sleep(0.1) until turtle.down()
- end
- for i = 1, downCount do
- repeat sleep(0.1) until turtle.up()
- end
- -- print("yay")
- return direction
- end
- function getTotalInvSize()
- local totalSize = 0
- for i = 1, 16 do
- totalSize = totalSize + turtle.getItemCount(i)
- end
- return totalSize
- end
- local function suckItems(suckDir, amount)
- local startingInv = getTotalInvSize()
- local x, y = term.getCursorPos()
- local missingAmount = 0
- local currentInv = 0
- turtle.select(1)
- -- local itemsAfterAction = 0
- local amount = tonumber(amount)
- -- print(amount)
- local turtleDir = nil
- if suckDir == "front" then
- turtleDir = turtle.suck
- elseif suckDir == "up" then
- turtleDir = turtle.suckUp
- elseif suckDir == "down" then
- turtleDir = turtle.suckDown
- end
- if amount ~= nil then
- repeat
- currentInv = getTotalInvSize() - startingInv
- missingAmount = amount - currentInv
- if turtleDir(missingAmount) == false then
- currentInv = getTotalInvSize() - startingInv
- if currentInv ~= amount then
- term.setCursorPos(x, y - 1)
- term.clearLine()
- textutils.slowPrint("Still missing "..missingAmount.." items.")
- end
- sleep(0.1)
- end
- until currentInv == amount
- else
- repeat sleep(0.1) until turtleDir() == false
- amount = getTotalInvSize() - startingInv
- end
- term.setCursorPos(x, y - 1)
- term.clearLine()
- shaka.changeColors(colors.black, colors.lightBlue)
- term.write("- Sucked items: ")
- shaka.changeColors(colors.black, colors.orange)
- term.write(amount)
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- end
- -- Function to drop items from turtle's inventory
- function dropItems(dropDir, amount, itemName)
- -- Determine which direction to drop items
- local x, y = term.getCursorPos()
- local dropAmount = 0
- local dropFunc = nil
- local amount = tonumber(amount) or 10000
- if dropDir == "front" then
- dropFunc = turtle.drop
- elseif dropDir == "up" then
- dropFunc = turtle.dropUp
- elseif dropDir == "down" then
- dropFunc = turtle.dropDown
- end
- -- Loop through turtle's inventory and drop specified items
- for i = 1, 16 do
- local itemDetail = turtle.getItemDetail(i)
- if itemDetail and itemDetail.count > 0 then
- if itemName == nil or itemDetail.name == itemName then
- turtle.select(i)
- if turtle.getItemCount() < amount then
- dropAmount = turtle.getItemCount()
- else
- dropAmount = amount
- end
- local currentSlotCount = turtle.getItemCount(i)
- local success, reason = dropFunc(dropAmount)
- if success then
- dropped = dropped + currentSlotCount - turtle.getItemCount(i)
- amount = amount and amount - currentSlotCount + turtle.getItemCount(i) ---
- else
- term.setCursorPos(x, y - 1)
- term.clearLine()
- shaka.changeColors(colors.black, colors.red)
- textutils.slowPrint("No space in inventory, retrying..")
- shaka.changeColors(colors.black, colors.white)
- dropItems(dropDir, amount, itemName)
- end
- if amount ~= nil and amount <= 0 then
- break
- elseif amount ~= nil and amount > 0 then
- dropItems(dropDir, amount, itemName)
- return
- end
- end
- end
- end
- turtle.select(1)
- term.setCursorPos(x, y - 1)
- term.clearLine()
- if not itemName then
- shaka.changeColors(colors.black, colors.magenta)
- term.write("- Dropped items: ")
- shaka.changeColors(colors.black, colors.orange)
- term.write(dropped)
- else
- local prettyName = shaka.prettyName(itemName)
- shaka.changeColors(colors.black, colors.magenta)
- term.write("- Dropped items ")
- shaka.changeColors(colors.black, colors.yellow)
- term.write("["..prettyName.."]")
- shaka.changeColors(colors.black, colors.white)
- term.write(": ")
- shaka.changeColors(colors.black, colors.orange)
- term.write(dropped)
- shaka.changeColors(colors.black, colors.white)
- end
- shaka.nextLine()
- dropped = 0
- end
- local function removeNada(inputString)
- -- Split the input string by space into words
- local words = {}
- for word in inputString:gmatch("%S+") do
- table.insert(words, word)
- end
- -- Check if the last word is "nada"
- if words[#words] == "nada" then
- -- Remove the last word
- table.remove(words, #words)
- end
- -- Join the words back into a single string
- local outputString = table.concat(words, " ")
- return outputString
- end
- local function displayItems(ID)
- avItems = {}
- for i =1, 16 do
- if turtle.getItemCount(i) > 0 then
- local data = turtle.getItemDetail(i)
- local itemName = data.name
- table.insert(avItems, itemName)
- end
- end
- avItems = textutils.serialize(avItems)
- rednet.send(ID, avItems, "showAvailableItems")
- end
- local function display_externalItems(side, receiver)
- local items = {}
- local inventory = peripheral.wrap(side)
- local availableItems = inventory.list()
- for k, v in pairs(availableItems) do
- if not shaka.tableContains(items, v.name) then
- table.insert(items, v.name)
- end
- end
- items = textutils.serialize(items)
- rednet.send(receiver, items, "items_Available")
- end
- local function determinePosition(savedLocationsFile)
- if direction == nil then direction = findDirection() end
- local xPos, yPos, zPos = gps.locate()
- local knownPositions = shaka.readFile(savedLocationsFile)
- for i =1, #knownPositions do
- shaka.split(knownPositions[i], " ")
- local savedX = tonumber(result[2])
- local savedY = tonumber(result[3])
- local savedZ = tonumber(result[4])
- local savedDirection = result[5]
- if xPos == savedX and yPos == savedY and zPos == savedZ and direction == savedDirection then
- workPosition = i
- return workPosition
- end
- end
- print("yo")
- return false
- end
- -- Function to reverse a command
- local function reverseCommand(command, redstoneSide, pulse)
- if command == "forward" then
- shaka.turtleBack()
- elseif command == "back" then
- shaka.turtleForward()
- elseif command == "up" then
- shaka.turtleDown()
- elseif command == "down" then
- shaka.turtleUp()
- elseif command == "left" then
- rightTurn()
- elseif command == "right" then
- leftTurn()
- elseif command == "redstone" and pulse ~= "pulse" then
- if redstone.getInput(redstoneSide) then
- redstone.setOutput(redstoneSide, false)
- else
- redstone.setOutput(redstoneSide, true)
- end
- else
- return nil
- end
- end
- local function redstoneTrigger(side, state)
- local state = tonumber(state)
- if state == 1 then
- repeat
- os.pullEvent("redstone")
- until redstone.getInput(side)
- elseif state == 2 then
- repeat
- os.pullEvent("redstone")
- until redstone.getInput(side) == false
- end
- end
- local function returnToStart(moveFile, positionSupply)
- local moveSet = nil
- local position = nil
- if positionSupply == nil then
- moveSet = shaka.readFile(moveFile)
- position = determinePosition(moveFile)
- else
- moveSet = moveFile
- position = positionSupply
- end
- shaka.changeColors(colors.black, colors.orange)
- local x, y = term.getCursorPos()
- print("- Returning to start")
- for i = position, 1, -1 do
- shaka.split(moveSet[i], " ")
- local commandName = result[1]
- local side = result[2]
- local pulse = result[3]
- if commandName == "goToStart" then
- break
- end
- reverseCommand(commandName, side, pulse)
- end
- term.setCursorPos(1, y)
- term.clearLine()
- shaka.changeColors(colors.black, colors.green)
- print("- Returned to start")
- if positionSupply == nil then
- shaka.writeFile(".startLocation", "yep") --indicate turtle is in starting position
- end
- end
- local function countItem(side, itemName) --- returns total amount of a certain item in inventory
- local inv = peripheral.wrap(side)
- local invCount = 0
- local tasks = {}
- for k, v in pairs(inv.list()) do
- tasks[#tasks+1] = function()
- if itemName then
- if v.name == itemName then -- if itemName is specified look only for that
- invCount = invCount + v.count
- end
- else -- if no itemName then return count of all items
- invCount = invCount + v.count
- end
- end
- end
- parallel.waitForAll(unpack(tasks))
- return invCount
- end
- local function getFillPercent(side) -- doesnt work with drawers!
- local inv = peripheral.wrap(side)
- local inventory_slots = inv.size()
- local inventory_maxItems = 0
- local tasks = {}
- local slotSizes = {}
- -- print(inventory_slots)
- for i = 1, inventory_slots do -- write all slot sizes to a table
- tasks[#tasks+1] = function()
- local itemDetail = inv.getItemDetail(i)
- if itemDetail then
- slotSizes[i] = itemDetail.maxCount -- use max stack of item if one is in the slot
- else
- slotSizes[i] = inv.getItemLimit(i) -- use the max size the slot can hold
- end
- end
- end
- parallel.waitForAll(unpack(tasks))
- for k, v in pairs(slotSizes) do -- add all sizes together
- inventory_maxItems = inventory_maxItems + tonumber(v)
- end
- local percentage = countItem(side) / inventory_maxItems * 100 -- total fill percentage
- return math.floor(percentage)
- end
- local function detectBlock(side)
- local turtleDir = nil
- local blockData = {}
- if side == "front" then
- turtleDir = turtle.inspect
- elseif side == "up" then
- turtleDir = turtle.inspectUp
- elseif side == "down" then
- turtleDir = turtle.inspectDown
- end
- local success, data = turtleDir()
- -- print(data.name)
- table.insert(blockData, "name " ..data.name)
- for k, v in pairs(data) do
- if k == "state" then
- for a, b in pairs(v) do
- -- print(a, b)
- table.insert(blockData, a.." "..tostring(b))
- end
- end
- end
- shaka.writeFile("blockData", blockData)
- return blockData
- end
- local function receiveRednetCommand(nameOfFile)
- shaka.clearScreen()
- shaka.turtleResetRedstone()
- if direction == nil then findDirection() end
- if compFound == false then findPocketComputer() end
- local moveTable = {}
- quitAll = false
- local startX, startY, startZ = gps.locate()
- local startDir = direction
- table.insert(moveTable, "start " ..startX.. " " ..startY.. " " ..startZ.. " " ..direction)
- local possibleKeys = { --possible movement commands
- forward = turtle.forward,
- left = turtle.turnLeft,
- right = turtle.turnRight,
- back = turtle.back,
- up = turtle.up,
- down = turtle.down
- }
- while not quitAll do
- local senderID, key = rednet.receive("recordRemote")
- -- print("here?")
- shaka.split(key, " ")
- local order = result[1]
- local order2 = result[2]
- local order3 = result[3]
- -- Check if the key is valid
- local validKey = possibleKeys[key] ~= nil
- -- Perform action based on key
- if validKey then
- local action = possibleKeys[key]
- if action == turtle.turnLeft then
- action = leftTurn
- elseif action == turtle.turnRight then
- action = rightTurn
- end
- if action() then
- local x, y, z = gps.locate()
- table.insert(moveTable, key.. " " ..x.. " " ..y.. " " ..z.. " " ..direction)
- shaka.changeColors(colors.black, colors.white)
- print("New move: "..key)
- if x == startX and z == startZ and y == startY and direction == startDir then
- rednet.send(senderID, "start", "positionUpdate")
- else
- rednet.send(senderID, "noStart", "positionUpdate")
- end
- else
- shaka.changeColors(colors.black, colors.orange)
- print("Not saving: "..key)
- end
- elseif key == "allDone" then
- local curX, curY, curZ = gps.locate()
- -- print("x", curX, startX, "Z", curZ, startZ, "y", curY, startY, direction, startDir)
- if curX == startX and curZ == startZ and curY == startY and direction == startDir then
- rednet.send(senderID, "yep", "remoteEnd")
- shaka.changeColors(colors.black, colors.orange)
- print("Recording finished..")
- quitAll = true
- break
- else
- rednet.send(senderID, "nope", "remoteEnd")
- local sender, msg = rednet.receive("remoteEnd")
- if msg == "y" then
- returnToStart(moveTable, #moveTable)
- table.insert(moveTable, "goToStart")
- rednet.send(sender, "done", "arrivedAtStart")
- end
- end
- elseif key == "delete" then
- shaka.split(moveTable[#moveTable], " ")
- local command = result[1]
- local side = result[2]
- local pulse = result[3]
- shaka.changeColors(colors.black, colors.red)
- if #moveTable > 1 then
- print("Undoing last move: "..command)
- reverseCommand(command, side, pulse)
- if #moveTable == 2 then
- rednet.send(senderID, "start", "positionUpdate")
- end
- moveTable[#moveTable] = nil
- else
- print("Already at start, can't undo more.")
- rednet.send(senderID, "start", "positionUpdate")
- end
- rednet.send(senderID, command, "instructionDeleteConfirm")
- elseif key == "showAvailable" then
- displayItems(senderID)
- elseif order == "blockInformation" then
- rednet.send(senderID, detectBlock(order2), "blockAnswer")
- elseif key == "displayExternal" then
- rednet.send(senderID, "which side?", "sideQuestion")
- local sender, msg = rednet.receive("sideAnswer")
- display_externalItems(msg, sender)
- elseif validKey == false then
- shaka.split(key, " ")
- local order = result[1]
- local orderInput2 = result[2]
- local orderInput3 = result[3]
- local orderInput4 = result[4]
- local orderInput5 = result[5]
- if orderInput2 == nil then
- table.insert(moveTable, key)
- elseif orderInput2 and orderInput3 == nil then
- table.insert(moveTable, order.." "..orderInput2)
- elseif order == "redstone" then
- table.insert(moveTable, order.." "..orderInput2.." "..orderInput3.." "..orderInput4)
- if orderInput3 == "on" then
- orderInput3 = true
- elseif orderInput3 == "off" then
- orderInput3 = false
- end
- if type(orderInput3) == "boolean" then
- redstone.setOutput(orderInput2, orderInput3)
- elseif orderInput3 == "pulse" then
- redstone.setOutput(orderInput2, true)
- sleep(1)
- redstone.setOutput(orderInput2, false)
- end
- elseif orderInput3 and (orderInput4 == nil or orderInput4 == "nada") then
- table.insert(moveTable, order.." "..orderInput2.." "..orderInput3)
- elseif orderInput4 and orderInput5 == nil then
- table.insert(moveTable, order.." "..orderInput2.." "..orderInput3.." "..orderInput4)
- elseif orderInput5 then
- table.insert(moveTable, order.." "..orderInput2.." "..orderInput3.." "..orderInput4.." "..orderInput5)
- end
- shaka.changeColors(colors.black, colors.lightBlue)
- key = removeNada(key)
- print("New instruction: "..key)
- end
- end
- -- shaka.writeFile(".startLocation", "yep") --indicate turtle is in starting position
- -- Write moveTable to a local file
- local file = fs.open(nameOfFile, "w") -- Open a file in write mode
- file.write(textutils.serialize(moveTable)) -- Serialize moveTable and write to file
- file.close() -- Close the file
- shaka.changeColors(colors.black, colors.yellow)
- print("\nSaved instructions to file: " ..nameOfFile)
- moveTable = {} -- reset table for next set of commands
- end
- local function replayMovesFromFile(fileName)
- local pos = nil
- local moves = shaka.readFile(fileName)
- local startLocation = shaka.readFile(".startLocation")
- if startLocation ~= "yep" then
- shaka.clearScreen()
- print("Determining location..\n")
- pos = determinePosition(fileName)
- else
- pos = 1
- shaka.split(moves[1], " ")
- direction = result[5]
- end
- -- Replay the moves
- shaka.writeFile(".startLocation", "nope")
- shaka.clearScreen()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- print("* Starting route..\n")
- shaka.changeColors(colors.black, colors.white)
- if pos ~= #moves then
- for i = pos + 1, #moves do
- shaka.split(moves[i], " ")
- local move = result[1] --main order
- local input2 = result[2] --rs direction, sleep time, drop/suck direction
- local input3 = result[3] --rs state, amount of items
- local input4 = result[4] --item name, redstone pulse sleep time,
- local input5 = result[5] --inventory item count
- if move == "forward" then
- shaka.turtleForward()
- elseif move == "left" then
- leftTurn()
- elseif move == "back" then
- shaka.turtleBack()
- elseif move == "right" then
- rightTurn()
- elseif move == "up" then
- shaka.turtleUp()
- elseif move == "down" then
- shaka.turtleDown()
- elseif move == "dropFiltered" or move == "drop" then
- shaka.changeColors(colors.black, colors.yellow)
- print("- Dropping items: "..input2..": "..input3)
- dropItems(input2, input3, input4)
- elseif move == "suck" then
- shaka.changeColors(colors.black, colors.yellow)
- print("- Sucking items: " ..input2..": "..input3)
- suckItems(input2, input3)
- elseif move == "redstone" then
- if input3 == "on" then
- input3 = true
- elseif input3 == "off" then
- input3 = false
- end
- if input3 ~= "pulse" then
- shaka.changeColors(colors.black, colors.red)
- term.write("- Changed RS")
- shaka.changeColors(colors.black, colors.yellow)
- term.write(" ["..input2.."]")
- shaka.changeColors(colors.black, colors.white)
- term.write(": ")
- shaka.changeColors(colors.black, colors.orange)
- term.write(input3)
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- redstone.setOutput(input2, input3)
- else
- shaka.changeColors(colors.black, colors.red)
- term.write("- Pulsing RS")
- shaka.changeColors(colors.black, colors.yellow)
- term.write(" ["..input2.."]")
- shaka.changeColors(colors.black, colors.white)
- term.write(":")
- shaka.changeColors(colors.black, colors.orange)
- term.write(" "..input4.."s")
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- redstone.setOutput(input2, true)
- sleep(tonumber(input4))
- redstone.setOutput(input2, false)
- end
- elseif move == "sleep" then
- print("- Waiting for " ..input2.." seconds.")
- input2 = tonumber(input2)
- sleep(input2)
- elseif move == "goToStart" then
- returnToStart(fileName)
- elseif move == "redstoneTrigger" then
- local displayState = nil
- input3 = tonumber(input3)
- if input3 == 1 then
- displayState = "on"
- elseif input3 == 2 then
- displayState = "off"
- end
- shaka.changeColors(colors.black, colors.yellow)
- print("- Waiting for rs "..displayState.. " - side: " ..input2..".")
- redstoneTrigger(input2, input3)
- shaka.changeColors(colors.black, colors.green)
- local x, y = term.getCursorPos()
- term.setCursorPos(x, y - 1)
- term.clearLine()
- print("- Redstone triggered successfully")
- elseif move == "inventoryTrigger" then
- repeatCounter = 0
- local _, startingY = term.getCursorPos()
- if input3 == "fillPercent" then
- local percent = getFillPercent(input2)
- if input4 == "above" then
- repeat
- percent = getFillPercent(input2)
- term.setCursorPos(1, startingY)
- shaka.changeColors(colors.black, colors.yellow)
- term.clearLine()
- print("Waiting for inv: "..percent.."% > "..input5.."%")
- repeatCounter = repeatCounter + 1
- if repeatCounter < 10 then
- -- sleep(0.1)
- else
- sleep(1)
- end
- until percent > tonumber(input5)
- shaka.changeColors(colors.black, colors.green)
- term.setCursorPos(1, startingY)
- term.clearLine()
- print("- Inv: [" ..input2.. "]", input4, input5.."%")
- elseif input4 == "below" then
- repeat
- percent = getFillPercent(input2)
- term.setCursorPos(1, startingY)
- shaka.changeColors(colors.black, colors.yellow)
- term.clearLine()
- print("Waiting for inv : "..percent.."% < "..input5.."%")
- if repeatCounter < 10 then
- -- sleep(0.1)
- else
- sleep(1)
- end
- until percent < tonumber(input5)
- shaka.changeColors(colors.black, colors.green)
- term.setCursorPos(1, startingY)
- term.clearLine()
- print("- Inv: [" ..input2.. "]", input4, input5.."%")
- end
- else
- local itemCount = countItem(input2, input3)
- if input4 == "above" then
- repeat
- itemCount = countItem(input2, input3)
- term.setCursorPos(1, startingY)
- shaka.changeColors(colors.black, colors.yellow)
- term.clearLine()
- print("Waiting for item: ", shaka.prettyName(input3), itemCount.." > "..input5)
- repeatCounter = repeatCounter + 1
- if repeatCounter < 10 then
- -- sleep(0.1)
- else
- sleep(1)
- end
- until itemCount > tonumber(input5)
- elseif input4 == "below" then
- repeat
- itemCount = countItem(input2, input3)
- term.setCursorPos(1, startingY)
- shaka.changeColors(colors.black, colors.yellow)
- term.clearLine()
- print("Waiting for item: ", shaka.prettyName(input3), itemCount.." < "..input5)
- repeatCounter = repeatCounter + 1
- if repeatCounter < 10 then
- -- sleep(0.1)
- else
- sleep(1)
- end
- until itemCount < tonumber(input5)
- end
- shaka.changeColors(colors.black, colors.green)
- term.setCursorPos(1, startingY)
- term.clearLine()
- term.write("- Inv: [" ..shaka.prettyName(input3).. "] ".. input4.. " ".. input5)
- shaka.nextLine()
- end
- elseif move == "blockTrigger" then
- local stopper = false
- shaka.changeColors(colors.black, colors.yellow)
- term.write("Waiting for block state: "..input3..": "..input4)
- shaka.nextLine()
- while stopper == false do
- local data = detectBlock(input2)
- for i = 1, #data do
- shaka.split(data[i], " ")
- if result[1] == input3 then
- if result[2] == input4 then
- stopper = true
- local x, y = term.getCursorPos()
- term.setCursorPos(1, y - 1)
- term.clearLine()
- shaka.changeColors(colors.black, colors.green)
- term.write("- Block "..input2.." ["..input3..":".. input4.."], success!")
- shaka.nextLine()
- else
- sleep(0.5)
- end
- end
- end
- end
- elseif false == false then ---marker to insert new stuff
- end
- end
- end
- shaka.changeColors(colors.gray, colors.green)
- shaka.nextLine()
- print("* Finished route.")
- shaka.changeColors(colors.black, colors.white)
- shaka.writeFile(".startLocation", "yep")
- dropped = 0
- end
- if args == 1 then
- receiveRednetCommand(moveSetFileName)
- elseif args == 2 then
- -- while true do
- replayMovesFromFile(moveSetFileName)
- -- sleep(3)
- -- end
- elseif args == 3 then
- returnToStart(moveSetFileName)
- elseif args == 4 then
- -- print(countItem("front", "minecraft:oak_log"))
- -- print(countItem("front"))
- -- print(getFillPercent("front"))
- -- test("top")
- -- display_externalItems("front")
- detectBlock("down")
- end
Add Comment
Please, Sign In to add comment