Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ping()
- rednet.broadcast("Nano_Mining_Ping")
- end
- function isFull()
- local c=0
- for i=4,16 do
- if turtle.getItemCount(i)==0 then
- c=c+1
- end
- end
- if c<2 then
- return true
- else
- return false
- end
- end
- function refuel()
- for i=1,16 do
- turtle.select(i)
- turtle.refuel(64)
- end
- end
- function dump()
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- for i=4,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function empty()
- if isFull() then dump() end
- end
- function dig()
- repeat turtle.dig() empty() ping() until not turtle.detect()
- end
- function digUp()
- repeat turtle.digUp() empty() ping() until not turtle.detectUp()
- end
- function digDown()
- repeat turtle.digDown() empty() ping() until not turtle.detectDown()
- end
- function forward()
- repeat
- while turtle.getFuelLevel() == 0 do
- print("waiting for fuel...")
- refuel()
- end
- until turtle.forward()
- ping()
- end
- function up()
- repeat until turtle.up()
- end
- function down()
- repeat until turtle.down()
- end
- rednet.open("right")
- while true do
- local a,b,c=rednet.receive()
- print(a,b,c)
- if a==69 or a==36 then
- if b == "left" then turtle.turnLeft() end
- if b == "right" then turtle.turnRight() end
- if b == "forward" then forward() end
- if b == "back" then turtle.back() end
- if b == "up" then up() end
- if b == "down" then down() end
- if b == "dig" then dig() end
- if b == "digUp" then digUp() end
- if b == "digDown" then digDown() end
- print(b)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement