-- startup.lua — GPS beacon using the built-in 'gps host' program
-- EDIT COORDS FOR THIS NODE:
local X, Y, Z = -925, 105, -1096
-- open wireless/Ender modem
local m = peripheral.find("modem", function(_,p) return p.isWireless() end)
assert(m, "no wireless modem")
rednet.open(peripheral.getName(m))
term.clear(); term.setCursorPos(1,1)
print(("GPS beacon @ (%.1f, %.1f, %.1f)"):format(X,Y,Z))
print("Hosting via 'gps host'...")
-- keep hosting; auto-restart if it exits
while true do
local ok, err = pcall(function()
shell.run("gps","host", tostring(X), tostring(Y), tostring(Z))
end)
if not ok then print("gps host error: "..tostring(err)) else print("gps host exited; restarting") end
sleep(2)
end
Comments