diff --git a/oc/app/protocol.iot b/oc/app/protocol.iot index 2660e5f..b5379c6 100644 --- a/oc/app/protocol.iot +++ b/oc/app/protocol.iot @@ -64,7 +64,7 @@ They are, as follows: 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.) -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.) 4: Descriptor (See Part 3.) diff --git a/oc/ecomponents/app-rsctrl b/oc/ecomponents/app-rsctrl index cc88d93..4fbc55b 100644 --- a/oc/ecomponents/app-rsctrl +++ b/oc/ecomponents/app-rsctrl @@ -4,14 +4,12 @@ UR=CG("redstone") function UT(p) - US=p - if#p>0then - UR.setOutput(1,15) - else - UR.setOutput(1,0) + if ({["true"]=0,["false"]=15})[p]then + US=p + UR.setOutput(1,UM[p]) end end -UT("") +UT("false") function UG(t) RS(t,4,"\xC0\x42active.\x81setName") end @@ -19,8 +17,7 @@ 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, -} + [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 diff --git a/oc/postprocess.lua b/oc/postprocess.lua index 7e0060b..13a1f07 100644 --- a/oc/postprocess.lua +++ b/oc/postprocess.lua @@ -21,7 +21,7 @@ local otext = text local function pass() text = text:gsub(".\n+.", function(i) local l = i:sub(1, 1) .. i:sub(#i) - if not l:match("[^%(%)%{%}].") then + if not l:match("[^%(%)%{%}%,].") then return l end return i:sub(1, 1) .. "\n" .. i:sub(#i) diff --git a/oc/uc-rsctl.lua b/oc/uc-rsctl.lua index 36bc45a..331b7ad 100644 --- a/oc/uc-rsctl.lua +++ b/oc/uc-rsctl.lua @@ -53,18 +53,12 @@ TS(t,g..S.char(a,1)..d)x=RP(j,R4)end RN[t..g]=x end j()end -- 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 +UR=CG("redstone")function UT(p)if ({["true"]=0,["false"]=15})[p]then +US=p +UR.setOutput(1,UM[p])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 +UT("false")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