Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hw = fs.open("report", fs.exists("report") and "a" or "w")
- local hr = fs.open("report", fs.exists("report") and "r")
- function welcome()
- print("Version 1.1")
- print("Skok dlina? (46)")
- length = read()
- num_lenght = tonumber(length)
- print("OK. Dlina ustanovlena: ", length)
- print("-----")
- print("Skok shirina?")
- width = read()
- num_width = tonumber(width)
- print("OK. Shirina ustanovlena: ", width)
- print("Write the side of the modem (left, right, front, back, bottom, top)")
- rednet_side = read()
- rednet.open(rednet_side)
- --Show total info about turtle settings
- print("~~~~~")
- print("Total info:")
- print("Length: ", length)
- print("Width: ", width)
- print("Fuel lvl: ", turtle.getFuelLevel())
- print("Rednet modem side: ", rednet_side)
- local x, y, z = gps.locate(5)
- if not x then --If gps.locate didn't work, it won't return anything. So check to see if it did.
- print("Failed to get my location!")
- else
- print("I am at (" .. x .. ", " .. y .. ", " .. z .. ")") --This prints 'I am at (1, 2, 3)' or whatever your coordinates are
- end
- print("~~~~~")
- end
- function recive_commands(status, time )
- local senderId, message, protocol = rednet.receive(time)
- local fuel = turtle.getFuelLevel()
- local x, y, z = gps.locate(5)
- print (x,y,z)
- local report = {status, fuel}
- if senderId then
- print("Sender: ", senderId)
- print(message)
- else
- print("Waiting for cactus...")
- end
- if senderId == 4 then
- if message == "status" then
- rednet.send(tonumber(senderId), report)
- end
- end
- end
- function collectStaff(num_width, num_lenght)
- while num_lenght > 0 do
- recive_commands("Collecting cactus...", 0.4)
- turtle.suck()
- turtle.suckUp()
- turtle.suckDown()
- turtle.forward()
- num_lenght = num_lenght - 1;
- print("Ostalos xodov: ", num_lenght)
- if num_lenght < 1 then
- turtle.turnRight()
- while num_width > 1 do
- turtle.forward()
- num_width = num_width - 1;
- end
- turtle.turnRight()
- print("Povorachivayu obratno...")
- print("Fuel lvl: ", turtle.getFuelLevel())
- end
- end
- end
- function make_circle()
- collectStaff(tonumber(width), tonumber(length))
- collectStaff(tonumber(width), tonumber(length))
- end
- function sleeping()
- print("No cactus for now. Sleep for 20 sec...")
- sleep(20)
- --num_width = tonumber(width)
- --num_lenght = tonumber(length)
- end
- --Here starts the initialization of the programm
- --Show welcome message and settings
- welcome()
- --Infinite loop for cheking the redstone signal for the turtle
- while true do
- if redstone.getInput("back") then
- make_circle()
- else
- recive_commands("Waiting for cactus...", 5)
- end
- end
- --Here ends the initialization of the programm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement