initialize
This commit is contained in:
commit
5b23ea99fd
43 changed files with 2336 additions and 0 deletions
1
GLONASS/README.md
Normal file
1
GLONASS/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
I originally made this project in 2022 as a proof of concept.
|
63
GLONASS/UNS.lua
Normal file
63
GLONASS/UNS.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
--[[
|
||||
Unitary Navigational System v0.0
|
||||
|
||||
This basic script attempts to consolidate a GPS constellation into a single computer. Because using 4 is plain wasteful!
|
||||
It was made out of project "GLONASS Tower" I made in 2022 after discovering CC
|
||||
|
||||
TODO: Bring back cool logging!
|
||||
]]
|
||||
|
||||
-- Modems declaration. Edit this
|
||||
local modems = {
|
||||
{
|
||||
id = "modem_id_here",
|
||||
pos = {
|
||||
x = 1,
|
||||
y = 1,
|
||||
z = 1
|
||||
},
|
||||
modem = nil,
|
||||
primary = true -- Highest modem, to increase coverage ever so slightly
|
||||
}
|
||||
}
|
||||
|
||||
-- Prepare all modems
|
||||
local primary_modem = nil
|
||||
for i = 1 .. #modems do
|
||||
modems[i].modem = peripheral.wrap(modems[i].id)
|
||||
if modems[i].primary then
|
||||
primary_modem = modems[i].modem
|
||||
end
|
||||
end
|
||||
if primary_modem == nil then
|
||||
primary_modem = modems[0].modem
|
||||
end
|
||||
primary_modem.open(gps.CHANNEL_GPS) -- Only *listen* on 1 modem to avoid repeats
|
||||
|
||||
-- Simple logging. It's not ideal but will do as a "temporary" solution
|
||||
local function log(message)
|
||||
term.write(message)
|
||||
term.setCursorPos(1, select(2, term.getCursorPos()) + 1)
|
||||
if select(2, term.getCursorPos()) >= select(2, term.getSize()) then
|
||||
term.scroll(1)
|
||||
term.setCursorPos(1, select(2, term.getCursorPos()) - 1)
|
||||
end
|
||||
end
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
log("UNS v0.0 starting...")
|
||||
|
||||
while true do
|
||||
-- Wait for a GPS query
|
||||
local event, side, channel, replyChannel, message, distance
|
||||
repeat
|
||||
event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
|
||||
until channel == gps.CHANNEL_GPS and message == "PING"
|
||||
log("Recieved request, distance: " .. distance)
|
||||
|
||||
-- Send data from all modems
|
||||
for _, modem in ipairs(modems) do
|
||||
modem.transmit(channel, replyChannel, modem.pos)
|
||||
log("Modem ID <" .. modem.id .. "> transmitted location")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue