Create HAM client

This commit is contained in:
minecartchris
2024-06-25 16:33:58 -05:00
committed by GitHub
parent 2486d5d1ae
commit 055bd04232

33
HAM client Normal file
View File

@@ -0,0 +1,33 @@
local m = peripheral.find("modem")
--local m = peripheral.wrap(jside)
print("frq 10501-10551")
local frq = tonumber(io.read())
if not (frq >= 10501 and frq <= 10551) then
error("choose a valid frequency!")
end
m.open(frq)
local msgBuffer = {}
parallel.waitForAny(
function()
while true do
print("Type your message:")
local msg = io.read()
m.transmit(frq, frq, {"dlhjs-ChrisHamRadio-dlhjs", msg})
for i, v in pairs(msgBuffer) do
print(v)
end
msgBuffer = {}
end
end,
function()
while true do
local _, _, _, _, msg = os.pullEvent("modem_message")
if type(msg)== "table" then
if msg[1] == "dlhjs-ChrisHamRadio-dlhjs" then
table.insert(msgBuffer, msg[2])
end
end
end
end)