Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- print("Sending Location Data...")
- time = 0
- locations = {
- {name = "Home",
- x = -18,
- y = 64,
- z = 54,
- range = 50,
- },
- {name = "Nix's Base",
- x = -50,
- y = 65,
- z = 361,
- range = 50,
- },
- }
- function getLocation()
- for i = 1, #locations do
- current = vector.new(gps.locate())
- location = vector.new(locations[i][2],locations[i][3],locations[i][4])
- currentLocation = location - current
- if currentLocation.x < locations[i]["range"] and currentLocation.z < locations[i]["range"] then
- if not afk then
- pos = locations[i]["name"]
- break
- elseif time < 60 then
- pos = (locations[i]["name"].." (AFK "..math.floor(time).."s)")
- else
- pos = (locaitons[i]["name"].." (AFK "..math.floor(time/60).."m)")
- end
- else
- pos = "Unknown"
- end
- end
- end
- function checkForAFK()
- x,y,z = gps.locate()
- if x == pastX and z == pastZ and y == pastY then
- time = time + .5
- else
- time = 0
- end
- if time >= 30 then
- afk = true
- else
- afk = false
- end
- pastX = x
- pastY = y
- pastZ = z
- end
- function send()
- rednet.send(84, {
- type = "Position",
- user = "Devin",
- x = x,
- y = y,
- z = z,
- status = pos,
- })
- sleep(.5)
- end
- while true do
- getLocation()
- checkForAFK()
- send()
- end
Advertisement
Add Comment
Please, Sign In to add comment