Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Side
- Distance = 10
- function Pos()
- fsp = io.open("Position", "w")
- fsp:write("Position = "..[["]]..Position..[["]])
- fsp:close()
- end
- rednet.open("right")
- if fs.exists("Position") then
- dofile("Position")
- else
- write("Am I front or back? ")
- Position = read()
- Pos()
- end
- function Check()
- if turtle.getItemCount(1) > turtle.getItemCount(2) then
- turtle.select(1)
- else
- turtle.select(2)
- end
- end
- function Heave()
- if Position == "front" then
- turtle.placeDown()
- while not turtle.forward() do
- end
- elseif Position == "back" then
- turtle.dig()
- while not turtle.forward() do
- end
- else
- error("Its not front or back")
- end
- rednet.send(ID, "Ho!")
- end
- function Changeover()
- Check()
- if Position == "front" then
- local BMan = 0
- repeat
- BMan = BMan+1
- while not turtle.back() do
- end
- until BMan == Distance
- while not turtle.down() do
- end
- Position = "back"
- elseif Position == "back" then
- while not turtle.up() do
- end
- while not turtle.up() do
- end
- local BMan = 0
- repeat
- BMan = BMan+1
- while not turtle.forward() do
- end
- until BMan == Distance
- while not turtle.down() do
- end
- Position = "front"
- end
- Pos()
- rednet.send(ID, "Changedover!")
- end
- while true do
- ID, Msg = rednet.receive()
- if Position == "front" then
- if Msg == "Heave!" then
- Heave()
- elseif Msg == "Changeover" then
- Changeover()
- end
- elseif Position == "back" then
- if Msg == "Heave!" then
- Heave()
- elseif Msg == "Changeover" then
- Changeover()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment