Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID = 1
- ID1 = 1
- Height = 1
- rednet.open("right")
- shell.run("clear")
- print("Press M to mine")
- function compare()
- if turtle.getItemCount(9) ~= 0 then
- shell.run("clear")
- print("Need to empty slot number 9!")
- repeat
- sleep(1)
- until turtle.getItemCount(9) == 0
- end
- for n=1,3 do
- turtle.select(n)
- if turtle.compare() then
- return true
- end
- end
- turtle.select(9)
- if turtle.compare() then
- return true
- end
- return false
- end
- function Mine()
- shell.run("clear")
- print("Mining")
- Times = 0
- if Height == 1 then
- Dir = "turtle.up()"
- else
- Dir = "turtle.down()"
- end
- for n=1,2 do
- if compare() then
- turtle.dig()
- loadstring(Dir)()
- if Dir == "turtle.up()" then
- Height = Height+1
- else
- Height = Height-1
- end
- else
- prepare()
- end
- end
- if compare() then
- turtle.dig()
- else
- prepare()
- end
- Check = os.startTimer(0.1)
- end
- function prepare()
- shell.run("clear")
- print("Waiting for you to press B so we can return to work")
- Status = "Stuck"
- while Height < 3 do
- turtle.up()
- Height = Height+1
- end
- turtle.back()
- turtle.back()
- end
- Times = 0
- Status = "idle"
- while true do
- event,param1,param2 = os.pullEvent()
- if event == "rednet_message" then
- if param1 == ID1 or param1 == ID then
- if param2 == "Checked In" then
- if ID == param1 and not OD then
- OD = "yes"
- Times = Times+1
- elseif ID1 == param1 and not OS then
- OS = "yes"
- Times = Times+1
- end
- if Times == 2 then
- rednet.send(ID, "Checked In")
- rednet.send(ID1, "Checked In")
- Times = 0
- OS = false
- OD = false
- if turtle.forward() then
- Mine()
- Check = os.startTimer(0.1)
- else
- repeat
- turtle.dig()
- sleep(0.1)
- until turtle.forward()
- Mine()
- end
- end
- elseif param2 == "Mine" then
- Status = "Mining"
- shell.run("clear")
- print("Mining")
- Mine()
- Check = os.startTimer(0.1)
- end
- end
- elseif event == "timer" and param1 == Check and Times < 2 and Status ~= "idle" then
- rednet.send(ID, "Checked In")
- rednet.send(ID1, "Checked In")
- Check = os.startTimer(0.1)
- elseif event == "char" then
- if param1 == "m" then
- if Status == "idle" then
- rednet.send(ID, "Mine")
- rednet.send(ID1, "Mine")
- Status = "Mining"
- Mine()
- else
- Status = "idle"
- end
- elseif param1 == "b" and Status == "Stuck" then
- turtle.forward()
- turtle.forward()
- shell.run("clear")
- print("Mining")
- Mine()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment