Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ SETTINGS ]]--
- X=9
- Y=9
- sendID=-1
- plant = "true"
- fuelID="minecraft:coal"
- sleepOnLoad=20
- --[[ END ]]--
- Status="on the Wrong Block :/"
- xb=1
- shell.run("clear")
- right="false"
- pause="false"
- stop="false"
- local fin="false"
- local f = Y*X+Y+X+10
- sId = tonumber(sendID)
- local function unload()
- if pause == "true" then
- fin ="true"
- shell.run(shell.getRunningProgram())
- else
- end
- Status="Loading/Unloading"
- for a=1,14 do
- turtle.select(a)
- turtle.dropDown()
- end
- for item=1, 16 do
- Isuc, Iname = turtle.getItemDetail()
- turtle.select(14)
- turtle.suckDown()
- if Iname == "minecraft:wheat_seeds" or "minecraft:carrot" or "minecraft:potato" or "Natura:barley.seeds" then
- turtle.transferTo(15)
- elseif Iname == FuelID then
- turtle.transferTo(16)
- end
- turtle.select(14)
- turtle.dropDown()
- end
- Status="sleeping"
- sleep(sleepOnLoad)
- turtle.select(16)
- turtle.refuel()
- turtle.select(14)
- turtle.dropDown()
- turtle.select(1)
- turtle.forward()
- xb=1
- right="false"
- end
- local function Fplant()
- Status = "planting"
- sucess, data = turtle.inspectDown()
- if plant == "true" then
- turtle.select(15)
- turtle.placeDown()
- turtle.select(1)
- else
- end
- end
- local function detect()
- if pause == "true" then
- else
- Status = "moving forward"
- sucess, data = turtle.inspectDown()
- if sucess == true then
- if data.metadata == 7 then
- Status = "farming"
- turtle.digDown()
- turtle.suckDown(2)
- turtle.select(2)
- turtle.transferTo(15)
- turtle.select(1)
- sleep(0.2)
- Fplant()
- end
- else
- turtle.digDown()
- Fplant()
- end
- end
- end
- local function curve()
- sucess, data = turtle.inspectDown()
- if right == "false" then
- xb = xb+1
- if xb <= X then
- detect()
- Status = "turning to the right"
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- right = "true"
- end
- elseif right == "true" then
- xb = xb+1
- if xb <= X then
- detect()
- Status = "turning to the left"
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- right = "false"
- end
- end
- end
- local function back()
- detect()
- Status = "going back"
- if right == "true" then
- turtle.turnRight()
- detect()
- for i1=3,xb do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- unload()
- end
- if right == "false" then
- turtle.turnLeft()
- turtle.turnLeft()
- detect()
- for i2=2,Y do
- turtle.forward()
- end
- turtle.turnRight()
- for i1=3,xb do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- unload()
- end
- end
- local function send()
- local function opnmdm()
- for i,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- if not rednet.isOpen(v) then rednet.open(v) end
- return true end
- end
- return false end
- opnmdm()
- while fin == "false" do
- Id, message, protocol = rednet.receive()
- if Id == sendID then
- if not os.getComputerLabel() then
- os.setComputerLabel("FeelingTurtle")
- end
- if message == "stop" then
- Status = "Stopped"
- stop = "true"
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Stopped!")
- end
- if message == "resume" then
- Status = "on the wrong block :/"
- stop = "false"
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Resumed")
- end
- if message == "status" then
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] is "..Status)
- end
- if message == "fuel" then
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] has "..turtle.getFuelLevel().." Fuel!")
- end
- if message == "type" then
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Is a Farming Turtle!")
- end
- if message == "help" then
- sleep(1)
- rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Commands: stop, resume, status, fuel, type")
- end
- if message and message ~= "" then
- rednet.send(sId, "Invalid command!")
- message=""
- else
- end
- end
- end
- end
- local function ui()
- while fin == "false" do
- x1, y1 = term.getSize()
- x2, y2 = term.getCursorPos()
- text = os.getComputerLabel().."[".. os.getComputerID().."]"
- term.setCursorPos(x1/2/string.len(text)+1,1)
- print(text)
- text = " Status: Is ".. Status.." "
- term.setCursorPos(x1/2/string.len(text),3)
- print(text)
- term.setCursorPos(1,4)
- print("---------------------------------------")
- sleep(0.01)
- term.setCursorPos(1,y2)
- end
- end
- local function shellP()
- while fin == "false" do
- x2, y2 = term.getCursorPos()
- if y2 > 13 then
- term.clear()
- term.setCursorPos(1,5)
- elseif y2 < 5 then
- term.setCursorPos(1,5)
- else
- end
- write("> ")
- c = read()
- if c == "stop" then
- Status = "Stopped"
- stop = "true"
- print(os.getComputerLabel() .."[".. os.getComputerID() .."] Stopped!")
- elseif c == "resume" then
- Status = "sleeping"
- stop = "false"
- print(os.getComputerLabel() .."[".. os.getComputerID() .."] Resumed")
- elseif c == "status" then
- print(os.getComputerLabel() .."[".. os.getComputerID() .."] is "..Status)
- elseif c == "fuel" then
- print(os.getComputerLabel() .."[".. os.getComputerID() .."] has "..turtle.getFuelLevel().." Fuel!")
- elseif c == "type" then
- print(os.getComputerLabel() .."[".. os.getComputerID() .."] Is a Felling Turtle!")
- elseif c == "exit" then
- print("Terminated!")
- pause = "true"
- turtle.select(1)
- sleep(0.5)
- os.reboot()
- elseif c == "help" then
- print("Commands: ")
- print("stop, resume, status, fuel, type, exit")
- else
- print("Invalid Command!")
- end
- sleep(2)
- term.clear()
- end
- end
- local function main()
- os.pullEvent =os.pullEventRaw
- unload()
- while turtle.getFuelLevel() < f do
- sleep(1)
- Status="out of Fuel!"
- turtle.select(16)
- turtle.refuel(64)
- end
- while true do
- if pause == "false" and stop == "false" then
- for i3=2,Y do
- detect()
- turtle.forward()
- end
- curve()
- if X < xb then
- pause="true"
- back()
- end
- end
- end
- sleep(0.01)
- end
- parallel.waitForAny(ui, send, shellP, main)
- shell.run(shell.getRunningProgram())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement