1
0
mirror of https://github.com/XeonSquared/OC-Copper.git synced 2024-11-15 14:28:06 +11:00
OC-Copper/oc/ecomponents/app-rsctrl

41 lines
767 B
Plaintext
Raw Normal View History

-- I, 20kdc, release this into the public domain.
-- No warranty is provided, implied or otherwise.
%-- EXAMPLE IoT Redstone Top Controller --
UR=CG("redstone")
function UT(p)
US=p
if#p>0then
UR.setOutput(1,15)
else
UR.setOutput(1,0)
end
end
UT("")
function UG(t)
RS(t,4,"\xC0\x42active.\x81setName")
end
N={
[0]=UG,
[1]=function(f)RS(f,4,"\xC1"..US)end,
[0x41]=function(_,p)UT(p)end,
[0x82]=function(_,p)if#p>0then CG("eeprom").setLabel(p)TH=p end end,
}
function UI(f,t,p,d)
local m=t==TH
if p==1 and(t=="*"or m)then
UG(f)
end
if p==4 and m then
if N[d:byte(1)]then
N[d:byte(1)](f,d:sub(2))
end
end
end
while true do local x={computer.pullSignal(1)}RF()
if"modem_message"==x[1]and 4957==x[4]and TC==x[6]then
RC(UI,TR(x[7]))
end
end