Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CLIENT_PORT = 0
- local SERVER_PORT = 1544
- local modem = peripheral.find("")
- modem.open(SERVER_PORT)
- print("I am listening to channel "..SERVER_PORT)
- while true do
- local event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message")
- local x, y, z = gps.locate(5)
- if message == "w" then
- turtle.forward()
- elseif message == "s" then
- turtle.back()
- elseif message == "a" then
- turtle.turnLeft()
- elseif message == "d" then
- turtle.turnRight()
- elseif message == "u" then
- turtle.up()
- elseif message == "do" then
- turtle.down()
- elseif message == "locate" then
- if not x then
- modem.transmit(CLIENT_PORT, SERVER_PORT, "Failed to get my location!")
- else
- modem.transmit(CLIENT_PORT, SERVER_PORT, "I am at (" .. x .. ", " .. z .. ", " .. y .. ")")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement