mirror of
https://github.com/XeonSquared/OC-Copper.git
synced 2024-11-15 06:18:05 +11:00
41 lines
758 B
Plaintext
41 lines
758 B
Plaintext
|
-- I, 20kdc, release this into the public domain.
|
||
|
-- No warranty is provided, implied or otherwise.
|
||
|
%-- EXAMPLE IoT Redstone Top Controller --
|
||
|
|
||
|
UR=C.proxy(C.list("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 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
|