mirror of
https://github.com/XeonSquared/OC-Copper.git
synced 2024-11-14 22:08:05 +11:00
Update IoT protocol for P9K-friendliness
This commit is contained in:
parent
2cd85360c6
commit
bb8671c202
@ -64,7 +64,7 @@ They are, as follows:
|
|||||||
|
|
||||||
0: Void (Only useful for Actions. Think 'ignore anything out of here'.
|
0: Void (Only useful for Actions. Think 'ignore anything out of here'.
|
||||||
1: Human-Readable String (Generic string that a user could feasibly type. No special characters.)
|
1: Human-Readable String (Generic string that a user could feasibly type. No special characters.)
|
||||||
2: Boolean (Length > 0 means true, otherwise false. Odd definition, but also convenient.)
|
2: Boolean ("false" means false, "true" means true, anything else is disallowed.)
|
||||||
3: Float (See Human-Readable String, but translated to a number by the device.)
|
3: Float (See Human-Readable String, but translated to a number by the device.)
|
||||||
4: Descriptor (See Part 3.)
|
4: Descriptor (See Part 3.)
|
||||||
|
|
||||||
|
@ -4,14 +4,12 @@
|
|||||||
|
|
||||||
UR=CG("redstone")
|
UR=CG("redstone")
|
||||||
function UT(p)
|
function UT(p)
|
||||||
|
if ({["true"]=0,["false"]=15})[p]then
|
||||||
US=p
|
US=p
|
||||||
if#p>0then
|
UR.setOutput(1,UM[p])
|
||||||
UR.setOutput(1,15)
|
|
||||||
else
|
|
||||||
UR.setOutput(1,0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
UT("")
|
UT("false")
|
||||||
function UG(t)
|
function UG(t)
|
||||||
RS(t,4,"\xC0\x42active.\x81setName")
|
RS(t,4,"\xC0\x42active.\x81setName")
|
||||||
end
|
end
|
||||||
@ -19,8 +17,7 @@ N={
|
|||||||
[0]=UG,
|
[0]=UG,
|
||||||
[1]=function(f)RS(f,4,"\xC1"..US)end,
|
[1]=function(f)RS(f,4,"\xC1"..US)end,
|
||||||
[0x41]=function(_,p)UT(p)end,
|
[0x41]=function(_,p)UT(p)end,
|
||||||
[0x82]=function(_,p)if#p>0then CG("eeprom").setLabel(p)TH=p end end,
|
[0x82]=function(_,p)if#p>0then CG("eeprom").setLabel(p)TH=p end end}
|
||||||
}
|
|
||||||
function UI(f,t,p,d)
|
function UI(f,t,p,d)
|
||||||
local m=t==TH
|
local m=t==TH
|
||||||
if p==1 and(t=="*"or m)then
|
if p==1 and(t=="*"or m)then
|
||||||
|
@ -21,7 +21,7 @@ local otext = text
|
|||||||
local function pass()
|
local function pass()
|
||||||
text = text:gsub(".\n+.", function(i)
|
text = text:gsub(".\n+.", function(i)
|
||||||
local l = i:sub(1, 1) .. i:sub(#i)
|
local l = i:sub(1, 1) .. i:sub(#i)
|
||||||
if not l:match("[^%(%)%{%}].") then
|
if not l:match("[^%(%)%{%}%,].") then
|
||||||
return l
|
return l
|
||||||
end
|
end
|
||||||
return i:sub(1, 1) .. "\n" .. i:sub(#i)
|
return i:sub(1, 1) .. "\n" .. i:sub(#i)
|
||||||
|
@ -53,18 +53,12 @@ TS(t,g..S.char(a,1)..d)x=RP(j,R4)end
|
|||||||
RN[t..g]=x
|
RN[t..g]=x
|
||||||
end j()end
|
end j()end
|
||||||
-- EXAMPLE IoT Redstone Top Controller --
|
-- EXAMPLE IoT Redstone Top Controller --
|
||||||
UR=CG("redstone")function UT(p)US=p
|
UR=CG("redstone")function UT(p)if ({["true"]=0,["false"]=15})[p]then
|
||||||
if#p>0then
|
US=p
|
||||||
UR.setOutput(1,15)else
|
UR.setOutput(1,UM[p])end
|
||||||
UR.setOutput(1,0)end
|
|
||||||
end
|
end
|
||||||
UT("")function UG(t)RS(t,4,"\xC0\x42active.\x81setName")end
|
UT("false")function UG(t)RS(t,4,"\xC0\x42active.\x81setName")end
|
||||||
N={[0]=UG,
|
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
|
||||||
[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
|
if p==1 and(t=="*"or m)then
|
||||||
UG(f)end
|
UG(f)end
|
||||||
if p==4 and m then
|
if p==4 and m then
|
||||||
|
Loading…
Reference in New Issue
Block a user