Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function turtleWrite(turtX, turtY, turtZ, turtDir, address)
- local a = fs.open("turt"..address, "w")
- a.writeLine(turtX)
- a.writeLine(turtY)
- a.writeLine(turtZ)
- a.writeLine(turtDir)
- a.close()
- end
- function turtleRead(address)
- local a = fs.open("turt"..address, "r")
- local x = a.readLine()
- local y = a.readLine()
- local z = a.readLine()
- local dir = a.readLine()
- print("Sending an update to turtle " ..address.. "!")
- rednet.send(address, x)
- rednet.send(address, y)
- rednet.send(address, z)
- rednet.send(address, dir)
- end
- print("Ready to receive signals!")
- rednet.open("right")
- while true do
- local id, command = rednet.receive()
- if command == "updatePos" then
- local flag = true
- while flag do
- local address, x = rednet.receive()
- if address == id then
- flag = false
- end
- end
- local flag = true
- while flag do
- local address, y = rednet.receive()
- if address == id then
- flag = false
- end
- end
- local flag = true
- while flag do
- local address, z = rednet.receive()
- if address == id then
- flag = false
- end
- end
- local flag = true
- while flag do
- local address, dir = rednet.receive()
- if address == id then
- flag = false
- end
- end
- turtleWrite(x, y, z, dir, id)
- elseif command == "needUpdate" then
- turtleRead(id)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement