Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.unloadAPI("sensors")
- os.loadAPI("/rom/apis/sensors")
- term.clear()
- term.setCursorPos(1,1)
- function printDict(data)
- for i,v in pairs(data) do
- print(tostring(i).." - "..tostring(v))
- end
- end
- function getXYZ()
- ctrl = sensors.getController()
- data = sensors.getSensors(ctrl)
- asSensor = data[1]
- data = sensors.getSensorInfo(ctrl,asSensor)
- asCoord = {}
- asCoord["x"] = data["xCoord"]
- asCoord["y"] = data["yCoord"]
- asCoord["z"] = data["zCoord"]
- return asCoord
- end
- print("Airship GPS Online - ID:"..os.getComputerID())
- a = getXYZ()
- print("Current - X."..a["x"].." Y."..a["y"].." Z."..a["z"])
- print("Waiting for ping...")
- rednet.open("left")
- while true do
- id, message = rednet.receive()
- if message == "ping" then
- a = getXYZ()
- print("Pinged by "..id..", sending: X."..a["x"].." Y."..a["y"].." Z."..a["z"].."...")
- rednet.send(id,textutils.serialize(a))
- term.write("Sent")
- else
- print("Invalid message from "..id..", ignoring...")
- end
- end
Add Comment
Please, Sign In to add comment