Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- -- GLOBALS
- local MY_POS = vector.new(gps.locate(2, false))
- local DIRS = {
- north = 1,
- east = 2,
- south = 3,
- west = 4
- }
- local MY_DIR = DIRS.north
- local MY_ID = os.getComputerID()
- local MY_LABEL = os.getComputerLabel()
- if MY_LABEL == nil then MY_LABEL = MY_ID end
- -- FUNCTIONS & STUFF
- local function getDir()
- while not turtle.forward() do
- turtle.dig()
- end
- local NEW_POS = vector.new(gps.locate(2, false))
- NEW_POS = NEW_POS:sub(MY_POS)
- if NEW_POS.z == -1 then
- turtle.back()
- return DIRS.north
- elseif NEW_POS.z == 1 then
- turtle.back()
- return DIRS.south
- elseif NEW_POS.x == -1 then
- turtle.back()
- return DIRS.west
- elseif NEW_POS.x == 1 then
- turtle.back()
- return DIRS.east
- end
- end
- local function updateInformation()
- MY_DIR = getDir()
- MY_POS = vector.new(gps.locate(2, false))
- MY_LABEL = os.getComputerLabel()
- end
- local function processRequest(senderId, msg)
- if msg == "%RQSTINFO" then
- updateInformation()
- return
- end
- end
- local function mainLoop()
- updateInformation()
- while true do
- rednet.broadcast("%CLTINFO!INF!"..MY_POS.x.."!INF!"..MY_POS.y.."!INF!"..MY_POS.z.."!INF!"..MY_DIR.."!INF!"..MY_ID.."!INF!", "botNetV1")
- os.sleep(1)
- end
- end
- -- STARTUP
- mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement