OpenComputers Von Neumann Machine Programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
985 B

local modem = require("component").modem
local Server = Server or require("server")
local computer = require("computer")
local event = require("event")
local os = require("os")
local gps = {}
gps.port = 20
gps.server = Server(gps.port, "gps")
function gps.startServer(x, y, z)
gps.x = x
gps.y = y
gps.z = z
gps.server:handle("/ping", function(...)
local tmp = {...}
computer.beep(500)
print(tmp[3])
modem.send(tmp[3], gps.port, "/location", tmp[7], x, y, z)
end)
end
function gps.closeServer()
gps.server:close()
end
function gps.getLocation()
gps.locator:handle("/location", function(...)
local tmp = {...}
end)
end
gps.startServer()
-- Soft interrupt
local interrupted = false
local interruptID = event.listen("interrupted", function() interrupted = true end)
while not interrupted do
os.sleep(1)
end
-- Don't forget to close the server
event.cancel(interruptID)
gps.closeServer()