Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------ButtonH----------------------------
- ----------------------MENU/PANEL API-------------------
- --------------------by 9551 DEV------------------------
- ---Copyright (c) 2021-2022 9551------------9551#0001---
- ---using this code in your project is fine!------------
- ---as long as you dont claim you made it---------------
- ---im cool with it, feel free to include---------------
- ---in your projects! discord: 9551#0001--------------
- ---you dont have to but giving credits is nice :)------
- -------------------------------------------------------
- -------------------------------------------------------
- --*! pastebin get LTDZZZEJ button
- --*functions usages
- --*API(ins, cord1, cord2, length, height)
- --*timetouch(timeout,monitor)
- --*touch()
- --*button(monitor, ins, cord1, cord2, text)
- --*counter(monitor, ins, cc, cord1, cord2, cv, max, min, col)
- --*fill(monitor, pos1, pos2, length, height)
- --*switch(monitor, cc, ins, pos1, pos2, col1, col2, col3, text)
- --*switchn(monitor, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
- --*bundle(side, color, state)
- --*signal(side, ins, col)
- --*sliderVer/Hor(monitor, ins, cc, pos1, pos2, length, color1, textCol)
- --*menu(monitor, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2) (returns menuout)
- --*bar(monitor, pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
- --*timeswitch(monitor, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
- --*render(monitor,text,x,y,textcol,backCol)
- --*menudata()
- --*frame(monitor, pos1, pos2, length, height, color3, color1, thicc)
- --*db allows you to get stored data from all functions that use stored data!
- --*how to use db: in your function for example switch you do b.switch("db",<data>) data is the storing position you want to get data of
- local e={}local t={}local a=require("cc.expect").expect function
- e.API(o,i,n,s,h)a(1,o,"table")a(2,i,"number")a(3,n,"number")a(4,s,"number")a(5,h,"number")if
- o==true then o={os.pullEvent("monitor_touch")}end if o[3]>=i and o[3]<=i+s-1
- then if o[4]>=n and o[4]<=n+h-1 then return true else return false end end end
- function e.touch()local r={os.pullEvent("monitor_touch")}return r end function
- e.timetouch(d,l)a(1,d,"number")a(2,l,"string")local u=os.startTimer(d)while
- true do local c={os.pullEvent()}if c[1]=="timer"and c[2]==u then if l==nil then
- end return{"timeout",l,1000,1000}elseif c[1]=="monitor_touch"and c[2]==l then
- return{c[1],c[2],c[3],c[4]}end end end function
- e.button(f,w,y,p,v)a(1,f,"string")a(2,w,"table")a(3,y,"number")a(4,p,"number")a(5,v,"string")if
- w[2]==f then if w~=nil then
- local m=peripheral.wrap(f) local x=e.API(w,y,p,#v,1)m.setCursorPos(y,p)m.write(v)return x
- end end end function e.counter(b,g,k,q,j,z,E,T,A)if b=="db"then if data==nil
- then return nil else return data[g]end end if b=="setdb"then if data==nil then
- return"no data to edit"else data[g]=k return"value changed too "..type(k)end
- end
- a(1,b,"string")a(2,g,"table")a(3,k,"number")a(4,q,"number")a(5,j,"number")a(6,z,"number")a(7,E,"number")a(8,T,"number")a(9,A,"string")if
- g[2]==b then if g~=nil then local O=peripheral.wrap(b)if data==nil then
- data={}for I=0,1000 do data[I]=0 end end
- O.setCursorPos(q,j)O.write("\24".." "..data[k])O.setCursorPos(q,j+1)O.write("\25")if
- e.API(g,q,j,1,1)==true then if data[k]<E then data[k]=data[k]+z
- O.setCursorPos(q,j)O.setTextColor(colors.green)O.write("\24".." "..data[k].." ")O.setCursorPos(q,j+1)O.setTextColor(colors.red)O.write("\25")O.setTextColor(colors[A])return
- data[k]end end end if e.API(g,q,j+1,1,1)==true then if data[k]>T then
- data[k]=data[k]-z
- m.setCursorPos(q,j)m.setTextColor(colors.green)m.write("\24".." "..data[k].." ")m.setCursorPos(q,j+1)m.setTextColor(colors.red)m.write("\25")m.setTextColor(colors[A])return
- data[k]end end end end function
- e.fill(N,S,H,R,D)a(1,N,"string")a(2,S,"number")a(3,H,"number")a(4,R,"number")a(5,D,"number")local
- L=peripheral.wrap(N)for U=0,D-1 do
- L.setCursorPos(S,H+U)L.write(string.rep(" ",R))end end function
- e.switch(C,M,F,W,Y,P,V,B,G)if C=="db"then if data1==nil then return nil else
- return data1[M]end end if C=="setdb"then if data1==nil then
- return"no data to edit"else data1[M]=F return"value changed too "..type(F)end
- end
- a(1,C,"string")a(2,M,"number")a(3,F,"table")a(4,W,"number")a(5,Y,"number")a(6,P,"string")a(7,V,"string")a(8,B,"string")a(9,G,"string")if
- F[2]==C then if F~=nil then local K=#G local Q=peripheral.wrap(C)if data1==nil
- then data1={}for J=0,1000 do data1[J]=false end end local function
- X()data1[M]=not data1[M]end if e.API(F,W,Y,#G,1)==true then X()end local
- Z=Q.getTextColor()local et=Q.getBackgroundColor()if data1[M]==true then
- Q.setBackgroundColor(colors[V])else Q.setBackgroundColor(colors[P])end
- Q.setCursorPos(W,Y)Q.setTextColor(colors[B])Q.write(G)Q.setTextColor(Z)Q.setBackgroundColor(et)return
- data1[M]end end end function e.switchn(tt,at,ot,it,nt,st,ht,rt,dt,lt)if
- tt=="db"then if data2==nil then return nil else return data2[at]end end if
- tt=="setdb"then if data2==nil then return"no data to edit"else data2[at]=ot
- return"value changed too "..type(ot)end end
- a(1,tt,"string")a(2,at,"number")a(3,ot,"table")a(4,it,"number")a(5,nt,"number")a(6,st,"string")a(7,ht,"string")a(8,rt,"string")a(9,dt,"string")a(10,lt,"string")if
- ot[2]==tt then if ot~=nil then local ut=#dt if#dt~=#lt then if#dt>#lt then
- ut=#dt else ut=#lt end end local ct=peripheral.wrap(tt)if data2==nil then
- data2={}for mt=0,1000 do data2[mt]=false end end local function
- ft()data2[at]=not data2[at]end if e.API(ot,it,nt,ut,1)==true then ft()end local
- wt=ct.getTextColor()local yt=ct.getBackgroundColor()if data2[at]==true then
- ct.setCursorPos(it,nt)if#dt~=#lt then ct.write(string.rep(" ",ut))end
- ct.setBackgroundColor(colors[ht])ct.setCursorPos(it,nt)ct.setTextColor(colors[rt])ct.write(lt)else
- ct.setCursorPos(it,nt)if#dt~=#lt then ct.write(string.rep(" ",ut))end
- ct.setBackgroundColor(colors[st])ct.setCursorPos(it,nt)ct.setTextColor(colors[rt])ct.write(dt)end
- ct.setTextColor(wt)ct.setBackgroundColor(yt)return data2[at]end end end
- function e.bundle(pt,vt,bt)a(1,pt,"string")a(2,vt,"number")a(3,bt,"boolean")if
- bt==true then
- rs.setBundledOutput(pt,colors.combine(rs.getBundledOutput(pt),vt))elseif
- bt==false then
- rs.setBundledOutput(pt,colors.subtract(rs.getBundledOutput(pt),vt))end end
- function
- e.signal(gt,kt,qt,jt)a(1,gt,"string")a(2,kt,"boolean","string")a(3,qt,"number")a(4,jt,"boolean")if
- kt=="clear"then rs.setBundledOutput(gt,0)else if jt==true then if kt=="on"then
- kt=true end if kt=="nil"then kt=false end end if kt~=nil then if kt==true then
- bundle(gt,qt,true)elseif kt==false then bundle(gt,qt,false)end end end end
- function e.sliderHor(xt,zt,Et,Tt,At,Ot,It,Nt)if xt=="db"then if data3==nil then
- return nil else return data3[zt]end end if xt=="setdb"then if data3==nil then
- return"no data to edit"else data3[zt]=Et
- return"value changed too "..type(Et)end end
- a(1,xt,"string")a(2,zt,"table")a(3,Et,"number")a(4,Tt,"number")a(5,At,"number")a(6,Ot,"number")a(7,It,"string")a(8,Nt,"string")if
- zt[2]==xt then if zt~=nil then m=peripheral.wrap(xt)local
- St=m.getBackgroundColor()local
- Ht=m.getTextColor()m.setBackgroundColor(colors[It])m.setTextColor(colors[Nt])m.setCursorPos(Tt,At)for
- Rt=0,Ot do m.write("-")m.setCursorPos(Tt+Rt,At)end if data3==nil then
- data3={}for Dt=0,1000 do data3[Dt]=0 end end local Lt=zt[3]if zt[4]==At and
- zt[3]>=Tt and zt[3]<=Tt+Ot-1 then m.setCursorPos(Lt,At)data3[Et]=Lt
- m.write("|")else m.setCursorPos(data3[Et],At)m.write("|")end
- m.setBackgroundColor(St)m.setTextColor(Ht)if data3[Et]-Tt>=0 then return
- data3[Et]-Tt elseif data3[Et]-Tt<0 then return 0 end end end end function
- e.sliderVer(Ut,Ct,Mt,Ft,Wt,Yt,Pt,Vt)if Ut=="db"then if data10==nil then return
- nil else return data10[Ct]end end if Ut=="setdb"then if data10==nil then
- return"no data to edit"else data10[Ct]=Mt
- return"value changed too "..type(Mt)end end
- a(1,Ut,"string")a(2,Ct,"table")a(3,Mt,"number")a(4,Ft,"number")a(5,Wt,"number")a(6,Yt,"number")a(7,Pt,"string")a(8,Vt,"string")if
- Ct[2]==Ut then if Ct~=nil then m=peripheral.wrap(Ut)local
- Bt=m.getBackgroundColor()local
- Gt=m.getTextColor()m.setBackgroundColor(colors[Pt])m.setTextColor(colors[Vt])m.setCursorPos(Ft,Wt)for
- Kt=0,Yt do m.write("\124")m.setCursorPos(Ft,Wt-Kt)end if data10==nil then
- data10={}for Qt=0,1000 do data10[Qt]=0 end end local Jt=Ct[4]if Ct[3]==Ft and
- Ct[4]<=Wt and Ct[4]>=Wt-Yt+1 then m.setCursorPos(Ft,Jt)data10[Mt]=Jt
- m.write("\xad")else m.setCursorPos(Ft,data10[Mt])m.write("\xad")end
- m.setBackgroundColor(Bt)m.setTextColor(Gt)if data10[Mt]-Ft>=0 then return
- data10[Mt]-Ft elseif data10[Mt]-Ft<0 then return 0 end end end end function
- e.render(Xt,Zt,ea,ta,aa,oa)a(1,Xt,"string")a(2,Zt,"string")a(3,ea,"number")a(4,ta,"number")a(5,aa,"string")a(6,oa,"string","number")local
- ia=peripheral.wrap(Xt)local na=ia.getBackgroundColor()local
- sa=ia.getTextColor()local ha={ia.getCursorPos()}ia.setTextColor(colors[aa])if
- type(oa)=="string"then ia.setBackgroundColor(colors[oa])elseif
- type(oa)=="number"then ia.setBackgroundColor(oa)end
- ia.setCursorPos(ea,ta)ia.write(Zt)ia.setBackgroundColor(na)ia.setTextColor(sa)ia.setCursorPos(ha[1],ha[2])end
- function
- e.menu(ra,da,la,ua,ca,ma,fa,wa,ya,pa,va)a(1,ra,"string")a(2,da,"table")a(3,la,"number")a(4,ua,"number")a(5,ca,"number")a(6,ma,"string")a(7,fa,"string")a(8,wa,"string")a(9,ya,"string","number","boolean","nil")a(10,pa,"boolean")a(11,va,"string","number","boolean","nil")if
- da[2]==ra then if thisIsUseless==nil then for ba=0,1000 do
- thisIsUseless={}thisIsUseless[ba]=false end end if not thisIsUseless[la]then if
- textcol2~=nil then e.render(ra,wa,ua,ca,ma,oldcol2)end end if da~=nil then
- local ga=peripheral.wrap(ra)local ka=ga.getTextColor()local
- qa=ga.getBackgroundColor()local ja=#wa if da[1]~="timeout"then if data4==nil
- then data4={}for xa=0,1000 do data4[xa]=false end end if data5==nil then
- data5={}for za=0,1000 do data5[za]=false end end if data6==nil then data6={}for
- Ea=0,1000 do data6[Ea]=false end end if e.API(da,ua,ca,ja,1)==true then
- data4[la]=wa data5[la]=ua data6[la]=ca local function Ta()for Aa=1,500 do if
- data4[Aa]~=false then
- ga.setBackgroundColor(qa)ga.setCursorPos(data5[Aa],data6[Aa])ga.setTextColor(colors[ma])ga.write(data4[Aa])end
- end end
- Ta()ga.setCursorPos(data5[la],data6[la])ga.setBackgroundColor(colors[fa])ga.setTextColor(colors[ma])ga.write(wa)ga.setTextColor(ka)ga.setBackgroundColor(qa)menuout=wa
- if ya==nil then return menuout else if pa==nil or pa==false then menuout=ya
- return menuout else menuout={ya,va}if menuout==nil then return 0 end return
- menuout end end end end end end thisIsUseless[la]=true if pa==true then if
- menuout==nil then menuout={ya,"nil"}end end end function e.menudata()if
- menuout~=nil then return menuout else return"no output"end end function
- e.timeswitch(Oa,Ia,Na,Sa,Ha,Ra,Da,La,Ua,Ca,Ma)if Oa=="db"then if data7==nil
- then return nil else return data7[Ia]end end if Oa=="setdb"then if data7==nil
- then return"no data to edit"else data7[Ia]=Na
- return"value changed too "..type(Na)end end
- a(1,Oa,"string")a(2,Ia,"table")a(3,Na,"number")a(4,Sa,"number")a(5,Ha,"number")a(6,Ra,"number")a(7,Da,"number")a(8,La,"string")a(9,Ua,"string")a(10,Ca,"string")a(11,Ma,"boolean")if
- Ia[2]==Oa then if Ia~=nil then local Fa=peripheral.wrap(Oa)local
- Wa=Fa.getTextColor()local
- Ya=Fa.getBackgroundColor()Fa.setBackgroundColor(colors[Ua])Fa.setTextColor(colors[La])if
- data7==nil then data7={}for Pa=0,1000 do data7[Pa]=false end end if data8==nil
- then data8={}for Va=0,1000 do data8[Va]=false end end if data8[Na]==false then
- data8[Na]=Da Fa.setCursorPos(Sa+6,Ha)Fa.write(data8[Na])end
- Fa.setCursorPos(Sa,Ha)Fa.write("start")if e.API(Ia,Sa,Ha,4,1)==true then
- data7[Na]=true end if data7[Na]==true then if data8[Na]>0 then repeat
- _=data8[Na]Fa.setBackgroundColor(colors[Ca])data8[Na]=data8[Na]-Ra
- Fa.setCursorPos(Sa+6,Ha)sleep(1)Fa.write(data8[Na])until data8[Na]==0
- return"ended"end end if Ma==true then data8[Na]=Da end
- Fa.setBackgroundColor(colors[Ua])Fa.setCursorPos(Sa+6,Ha)Fa.write(data8[Na])Fa.setTextColor(Wa)Fa.setBackgroundColor(Ya)end
- end end function
- e.bar(Ba,Ga,Ka,Qa,Ja,Xa,Za,eo,to,ao,oo,io,no,so,ho,ro)a(1,Ba,"string")a(2,Ga,"number")a(3,Ka,"number")a(4,Qa,"number")a(5,Ja,"number")a(6,Xa,"number")a(7,Za,"number")a(8,eo,"string")a(9,to,"string")a(10,ao,"string")a(11,oo,"boolean")a(12,io,"boolean")a(13,no,"string")a(14,so,"boolean")a(15,ho,"boolean")a(16,ro,"boolean")if
- Xa==nil or Xa<0 then Xa=0 end if so==nil then end if Xa~=nil then local
- lo=peripheral.wrap(Ba)oldcol=lo.getBackgroundColor()oldcol1=lo.getTextColor()lo.setTextColor(colors[ao])local
- function
- uo()lo.setBackgroundColor(colors[eo])e.fill(Ba,Ga-1,Ka-Ja,Qa,Ja*2)lo.setBackgroundColor(oldcol)xm=lo.getBackgroundColor()xb=lo.getTextColor()lo.setTextColor(xm)lo.setBackgroundColor(xb)lo.setCursorPos(Ga-1,Ka-Ja)if
- ro then lo.setBackgroundColor(colors[ao])end if ro then
- lo.write(string.rep("\x83",Qa+1))lo.setTextColor(xb)lo.setBackgroundColor(xm)else
- lo.write("\159"..string.rep("\143",Qa-1))lo.setTextColor(xb)lo.setBackgroundColor(xm)lo.write("\144")end
- if ro then lo.setBackgroundColor(colors[ao])end lo.setCursorPos(Ga-1,Ka+Ja)if
- ro then lo.write(string.rep("\x8c",Qa+1))else
- lo.write("\130"..string.rep("\131",Qa-1).."\129")end for co=0,Ja*2-2 do if not
- ro then lo.setTextColor(xm)lo.setBackgroundColor(xb)end
- lo.setCursorPos(Ga-1,Ka+co-Ja+1)if ro then lo.setBackgroundColor(colors[ao])end
- lo.write("\x95")lo.setCursorPos(Ga-2+(Qa+1),Ka+co-Ja+1)if not ro then
- lo.setTextColor(xb)lo.setBackgroundColor(xm)end lo.write("\x95")end end if
- ho~=false then uo()else e.fill(Ba,Ga-1,Ka-Ja,Qa,Ja*2)end local mo=Xa/Za*Qa
- local fo=Xa/Za*Ja local wo=math.ceil(fo)local yo=wo*2-2 local po=Ka+Ja
- lo.setBackgroundColor(colors[to])if io==false or io==nil then
- e.fill(Ba,Ga,Ka-Ja+1,mo-1,Ja*2-1)else e.fill(Ba,Ga,po-1-yo,Qa-1,yo+1)end if
- oo==true then lo.setCursorPos(Ga,Ka)lo.setTextColor(colors[ao])if io==true then
- if so then if Xa>=Za/2 then lo.setBackgroundColor(colors[to])else
- lo.setBackgroundColor(colors[eo])end else if Xa>=Za/2-Za/Ja then
- lo.setBackgroundColor(colors[to])else lo.setBackgroundColor(colors[eo])end end
- elseif io==false then lo.setCursorPos(Ga,Ka)lo.setTextColor(colors[ao])if
- io==true then if Xa>=1 then lo.setBackgroundColor(colors[to])else
- lo.setBackgroundColor(colors[eo])end end end if so then
- lo.write(Xa.."/"..Za)lo.setCursorPos(Ga,Ka+1)lo.write(no)else
- lo.write(Xa.."/"..Za.." "..no)end
- lo.setBackgroundColor(oldcol)lo.setTextColor(oldcol1)end
- lo.setTextColor(oldcol1)lo.setBackgroundColor(oldcol)end end function
- e.frame(vo,bo,go,ko,qo,jo,xo,zo)a(1,vo,"string")a(2,bo,"number")a(3,go,"number")a(4,ko,"number")a(5,qo,"number")a(6,jo,"string")a(7,xo,"string")a(8,zo,"boolean","nil")local
- Eo=peripheral.wrap(vo)local To=Eo.getBackgroundColor()local
- Ao=Eo.getTextColor()Eo.setBackgroundColor(colors[xo])e.fill(vo,bo-1,go-qo,ko,qo*2)Eo.setBackgroundColor(To)xm=Eo.getBackgroundColor()xb=Eo.getTextColor()Eo.setTextColor(xm)Eo.setBackgroundColor(xb)Eo.setCursorPos(bo-1,go-qo)if
- zo then
- Eo.setBackgroundColor(colors[jo])Eo.setTextColor(To)Eo.write(string.rep("\x83",ko+1))Eo.setTextColor(xb)Eo.setBackgroundColor(xm)else
- Eo.setTextColor(To)Eo.setBackgroundColor(colors[jo])Eo.write("\159"..string.rep("\143",ko-1))Eo.setTextColor(colors[jo])Eo.setBackgroundColor(To)Eo.write("\144")end
- Eo.setCursorPos(bo-1,go+qo)if zo then
- Eo.setBackgroundColor(To)Eo.setTextColor(colors[jo])Eo.write(string.rep("\x8f",ko+1))Eo.setBackgroundColor(colors[xo])Eo.setTextColor(colors[jo])else
- Eo.write("\130"..string.rep("\131",ko-1).."\129")end for Oo=0,qo*2-2 do if not
- zo then Eo.setTextColor(xm)Eo.setBackgroundColor(xb)end
- Eo.setCursorPos(bo-1,go+Oo-qo+1)if zo then Eo.setBackgroundColor(colors[jo])end
- Eo.setBackgroundColor(colors[jo])Eo.write("\x95")Eo.setCursorPos(bo-2+(ko+1),go+Oo-qo+1)if
- not zo then Eo.setTextColor(xb)Eo.setBackgroundColor(xm)end
- Eo.setTextColor(colors[jo])Eo.write("\x95")end
- Eo.setBackgroundColor(To)Eo.setTextColor(Ao)end function
- t.API(Io,No,So,Ho,Ro)a(1,Io,"table")a(2,No,"number")a(3,So,"number")a(4,Ho,"number")a(5,Ro,"number")if
- Io==true then Io={os.pullEvent("mouse_click")}end if Io[3]>=No and
- Io[3]<=No+Ho-1 then if Io[4]>=So and Io[4]<=So+Ro-1 then return true else
- return false end end end function t.touch()local
- Do={os.pullEvent("mouse_click")}return Do end function
- t.timetouch(Lo)a(1,Lo,"number")local Uo=os.startTimer(Lo)while true do local
- Co={os.pullEvent()}if Co[1]=="timer"and Co[2]==Uo then
- return{"timeout","tout",1000,1000}elseif Co[1]=="mouse_click"then
- return{Co[1],Co[2],Co[3],Co[4]}end end end function
- t.button(Mo,Fo,Wo,Yo,Po)a(1,Mo,"number")a(2,Fo,"table")a(3,Wo,"number")a(4,Yo,"number")a(5,Po,"string")if
- Fo[2]==Mo or Fo[2]=="tout"then if Fo~=nil then
- local x=t.API(Fo,Wo,Yo,#Po,1)term.setCursorPos(Wo,Yo)term.write(Po)return x end end
- end function t.counter(Vo,Bo,Go,Ko,Qo,Jo,Xo,Zo,ei)if Vo=="db"then if data==nil
- then return nil else return data[Bo]end end if Vo=="setdb"then if data==nil
- then return"no data to edit"else data[Bo]=Go
- return"value changed too "..type(Go)end end
- a(1,Vo,"number")a(2,Bo,"table")a(3,Go,"number")a(4,Ko,"number")a(5,Qo,"number")a(6,Jo,"number")a(7,Xo,"number")a(8,Zo,"number")a(9,ei,"string")if
- Bo[2]==Vo or Bo[2]=="tout"then if Bo~=nil then if data==nil then data={}for
- ti=0,1000 do data[ti]=0 end end
- term.setCursorPos(Ko,Qo)term.write("\24".." "..data[Go])term.setCursorPos(Ko,Qo+1)term.write("\25")if
- t.API(Bo,Ko,Qo,1,1)==true then if data[Go]<Xo then data[Go]=data[Go]+Jo
- term.setCursorPos(Ko,Qo)term.setTextColor(colors.green)term.write("\24".." "..data[Go].." ")term.setCursorPos(Ko,Qo+1)term.setTextColor(colors.red)term.write("\25")term.setTextColor(colors[ei])return
- data[Go]end end end if t.API(Bo,Ko,Qo+1,1,1)==true then if data[Go]>Zo then
- data[Go]=data[Go]-Jo
- term.setCursorPos(Ko,Qo)term.setTextColor(colors.green)term.write("\24".." "..data[Go].." ")term.setCursorPos(Ko,Qo+1)term.setTextColor(colors.red)term.write("\25")term.setTextColor(colors[ei])return
- data[Go]end end end end function
- t.fill(ai,oi,ii,ni)a(1,ai,"number")a(2,oi,"number")a(3,ii,"number")a(4,ni,"number")for
- si=0,ni-1 do term.setCursorPos(ai,oi+si)term.write(string.rep(" ",ii))end end
- function t.switch(hi,ri,di,li,ui,ci,mi,fi,wi)if hi=="db"then if data1==nil then
- return nil else return data1[ri]end end if hi=="setdb"then if data1==nil then
- return"no data to edit"else data1[ri]=di
- return"value changed too "..type(di)end end
- a(1,hi,"number")a(2,ri,"number")a(3,di,"table")a(4,li,"number")a(5,ui,"number")a(6,ci,"string")a(7,mi,"string")a(8,fi,"string")a(9,wi,"string")if
- di[2]==hi or di[2]=="tout"then if di~=nil then local yi=#wi if data1==nil then
- data1={}for pi=0,1000 do data1[pi]=false end end local function
- vi()data1[ri]=not data1[ri]end if t.API(di,li,ui,#wi,1)==true then vi()end
- local bi=term.getTextColor()local gi=term.getBackgroundColor()if
- data1[ri]==true then term.setBackgroundColor(colors[mi])else
- term.setBackgroundColor(colors[ci])end
- term.setCursorPos(li,ui)term.setTextColor(colors[fi])term.write(wi)term.setTextColor(bi)term.setBackgroundColor(gi)return
- data1[ri]end end end function t.switchn(ki,qi,ji,xi,zi,Ei,Ti,Ai,Oi,Ii)if
- ki=="db"then if data2==nil then return nil else return data2[qi]end end if
- ki=="setdb"then if data2==nil then return"no data to edit"else data2[qi]=ji
- return"value changed too "..type(ji)end end
- a(1,ki,"number")a(2,qi,"number")a(3,ji,"table")a(4,xi,"number")a(5,zi,"number")a(6,Ei,"string")a(7,Ti,"string")a(8,Ai,"string")a(9,Oi,"string")a(10,Ii,"string")if
- ji[2]==ki or ji[2]=="tout"then if ji~=nil then local Ni=#Oi if#Oi~=#Ii then
- if#Oi>#Ii then Ni=#Oi else Ni=#Ii end end if data2==nil then data2={}for
- Si=0,1000 do data2[Si]=false end end local function Hi()data2[qi]=not
- data2[qi]end if t.API(ji,xi,zi,Ni,1)==true then Hi()end local
- Ri=term.getTextColor()local Di=term.getBackgroundColor()if data2[qi]==true then
- term.setCursorPos(xi,zi)if#Oi~=#Ii then term.write(string.rep(" ",Ni))end
- term.setBackgroundColor(colors[Ti])term.setCursorPos(xi,zi)term.setTextColor(colors[Ai])term.write(Ii)else
- term.setCursorPos(xi,zi)if#Oi~=#Ii then term.write(string.rep(" ",Ni))end
- term.setBackgroundColor(colors[Ei])term.setCursorPos(xi,zi)term.setTextColor(colors[Ai])term.write(Oi)end
- term.setTextColor(Ri)term.setBackgroundColor(Di)return data2[qi]end end end
- function t.bundle(Li,Ui,Ci)a(1,Li,"string")a(2,Ui,"number")a(3,Ci,"boolean")if
- type(Li)=="string"and type(Ui)=="number"and type(Ci)=="boolean"then if Ci==true
- then rs.setBundledOutput(Li,colors.combine(rs.getBundledOutput(Li),Ui))elseif
- Ci==false then
- rs.setBundledOutput(Li,colors.subtract(rs.getBundledOutput(Li),Ui))end else
- error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")end
- end function
- t.signal(Mi,Fi,Wi,Yi)a(1,Mi,"string")a(2,Fi,"boolean","string")a(3,Wi,"number")a(4,Yi,"boolean")if
- Fi=="clear"then rs.setBundledOutput(Mi,0)else if Yi==true then if Fi=="on"then
- Fi=true end if Fi=="nil"then Fi=false end end if Fi~=nil then if Fi==true then
- bundle(Mi,Wi,true)elseif Fi==false then bundle(Mi,Wi,false)end end end end
- function t.sliderHor(Pi,Vi,Bi,Gi,Ki,Qi,Ji,Xi)if Pi=="db"then if data3==nil then
- return nil else return data3[Vi]end end if Pi=="setdb"then if data3==nil then
- return"no data to edit"else data3[Vi]=Bi
- return"value changed too "..type(Bi)end end
- a(1,Pi,"number")a(2,Vi,"table")a(3,Bi,"number")a(4,Gi,"number")a(5,Ki,"number")a(6,Qi,"number")a(7,Ji,"string")a(8,Xi,"string")if
- Vi[2]==Pi or Vi[2]=="tout"then if Vi~=nil then local
- Zi=term.getBackgroundColor()local
- en=term.getTextColor()term.setBackgroundColor(colors[Ji])term.setTextColor(colors[Xi])term.setCursorPos(Gi,Ki)for
- tn=0,Qi do term.write("-")term.setCursorPos(Gi+tn,Ki)end if data3==nil then
- data3={}for an=0,1000 do data3[an]=0 end end local on=Vi[3]if Vi[4]==Ki and
- Vi[3]>=Gi and Vi[3]<=Gi+Qi-1 then term.setCursorPos(on,Ki)data3[Bi]=on
- term.write("|")else term.setCursorPos(data3[Bi],Ki)term.write("|")end
- term.setBackgroundColor(Zi)term.setTextColor(en)if data3[Bi]-Gi>=0 then return
- data3[Bi]-Gi elseif data3[Bi]-Gi<0 then return 0 end end end end function
- t.sliderVer(nn,sn,hn,rn,dn,ln,un,cn)if nn=="db"then if data10==nil then return
- nil else return data10[sn]end end if nn=="setdb"then if data10==nil then
- return"no data to edit"else data10[sn]=hn
- return"value changed too "..type(hn)end end
- a(1,nn,"number")a(2,sn,"table")a(3,hn,"number")a(4,rn,"number")a(5,dn,"number")a(6,ln,"number")a(7,un,"string")a(8,cn,"string")if
- sn[2]==nn or sn[2]=="tout"then if sn~=nil then local
- mn=term.getBackgroundColor()local
- fn=term.getTextColor()term.setBackgroundColor(colors[un])term.setTextColor(colors[cn])term.setCursorPos(rn,dn)for
- wn=0,ln do term.write("\124")term.setCursorPos(rn,dn-wn)end if data10==nil then
- data10={}for yn=0,1000 do data10[yn]=0 end end local pn=sn[4]if sn[3]==rn and
- sn[4]<=dn and sn[4]>=dn-ln+1 then term.setCursorPos(rn,pn)data10[hn]=pn
- term.write("\xad")else term.setCursorPos(rn,data10[hn])term.write("\xad")end
- term.setBackgroundColor(mn)term.setTextColor(fn)if data10[hn]-rn>=0 then return
- data10[hn]-rn elseif data10[hn]-rn<0 then return 0 end end end end function
- t.render(vn,bn,gn,kn,qn)a(1,vn,"string")a(2,bn,"number")a(3,gn,"number")a(4,kn,"string")a(5,qn,"string","number")local
- jn=term.getBackgroundColor()local xn=term.getTextColor()local
- zn={term.getCursorPos()}term.setTextColor(colors[kn])if type(qn)=="string"then
- term.setBackgroundColor(colors[qn])elseif type(qn)=="number"then
- term.setBackgroundColor(qn)end
- term.setCursorPos(bn,gn)term.write(vn)term.setBackgroundColor(jn)term.setTextColor(xn)term.setCursorPos(zn[1],zn[2])end
- function
- t.menu(En,Tn,An,On,In,Nn,Sn,Hn,Rn,Dn,Ln)a(1,En,"number")a(2,Tn,"table")a(3,An,"number")a(4,On,"number")a(5,In,"number")a(6,Nn,"string")a(7,Sn,"string")a(8,Hn,"string")a(9,Rn,"string","number","boolean","nil")a(10,Dn,"boolean")a(11,Ln,"string","number","boolean","nil")if
- Tn[2]==En or Tn[2]=="tout"then if thisIsUseless==nil then for Un=0,1000 do
- thisIsUseless={}thisIsUseless[Un]=false end end if not thisIsUseless[An]then
- t.render(Hn,On,In,Nn,oldcol2)end if Tn~=nil then local
- Cn=term.getTextColor()local Mn=term.getBackgroundColor()local Fn=#Hn if
- Tn[1]~="timeout"then if data4==nil then data4={}for Wn=0,1000 do
- data4[Wn]=false end end if data5==nil then data5={}for Yn=0,1000 do
- data5[Yn]=false end end if data6==nil then data6={}for Pn=0,1000 do
- data6[Pn]=false end end if t.API(Tn,On,In,Fn,1)==true then data4[An]=Hn
- data5[An]=On data6[An]=In local function Vn()for Bn=1,500 do if
- data4[Bn]~=false then
- term.setBackgroundColor(Mn)term.setCursorPos(data5[Bn],data6[Bn])term.setTextColor(colors[Nn])term.write(data4[Bn])end
- end end
- Vn()term.setCursorPos(data5[An],data6[An])term.setBackgroundColor(colors[Sn])term.setTextColor(colors[Nn])term.write(Hn)term.setTextColor(Cn)term.setBackgroundColor(Mn)menuout=Hn
- if Rn==nil then return menuout else if Dn==nil or Dn==false then menuout=Rn
- return menuout else menuout={Rn,Ln}if menuout==nil then return 0 end return
- menuout end end end end end end thisIsUseless[An]=true if Dn==true then if
- menuout==nil then menuout={Rn,"nil"}end end end function t.menudata()if
- menuout~=nil then return menuout else return"no output"end end function
- t.timeswitch(Gn,Kn,Qn,Jn,Xn,Zn,es,ts,as,is,ns)if Gn=="db"then if data7==nil
- then return nil else return data7[Kn]end end if Gn=="setdb"then if data7==nil
- then return"no data to edit"else data7[Kn]=Qn
- return"value changed too "..type(Qn)end end
- a(1,Gn,"number")a(2,Kn,"table")a(3,Qn,"number")a(4,Jn,"number")a(5,Xn,"number")a(6,Zn,"number")a(7,es,"number")a(8,ts,"string")a(9,as,"string")a(10,is,"string")a(11,ns,"boolean")if
- Kn[2]==Gn or Kn[2]=="tout"then if Kn~=nil then local
- ss=term.getTextColor()local
- hs=term.getBackgroundColor()term.setBackgroundColor(colors[as])term.setTextColor(colors[ts])if
- data7==nil then data7={}for ds=0,1000 do data7[ds]=false end end if data8==nil
- then data8={}for ls=0,1000 do data8[ls]=false end end if data8[Qn]==false then
- data8[Qn]=es term.setCursorPos(Jn+6,Xn)term.write(data8[Qn])end
- term.setCursorPos(Jn,Xn)term.write("start")if t.API(Kn,Jn,Xn,4,1)==true then
- data7[Qn]=true end if data7[Qn]==true then if data8[Qn]>0 then repeat
- _=data8[Qn]term.setBackgroundColor(colors[is])data8[Qn]=data8[Qn]-Zn
- term.setCursorPos(Jn+6,Xn)sleep(1)term.write(data8[Qn])until data8[Qn]==0
- return"ended"end end if ns==true then data8[Qn]=es end
- term.setBackgroundColor(colors[as])term.setCursorPos(Jn+6,Xn)term.write(data8[Qn])term.setTextColor(ss)term.setBackgroundColor(hs)end
- end end function
- t.bar(us,cs,ms,fs,ws,ys,ps,vs,bs,gs,ks,qs,js,xs,zs)a(1,us,"number")a(2,cs,"number")a(3,ms,"number")a(4,fs,"number")a(5,ws,"number")a(6,ys,"number")a(7,ps,"string")a(8,vs,"string")a(9,bs,"string")a(10,gs,"boolean")a(11,ks,"boolean")a(12,qs,"string")a(13,js,"boolean")a(14,xs,"boolean")a(15,zs,"boolean")if
- ws==nil or ws<0 then ws=0 end if js==nil then end if ws~=nil then
- oldcol=term.getBackgroundColor()oldcol1=term.getTextColor()term.setTextColor(colors[bs])local
- function
- Es()term.setBackgroundColor(colors[ps])t.fill(us-1,cs-fs,ms,fs*2)term.setBackgroundColor(oldcol)xm=term.getBackgroundColor()xb=term.getTextColor()term.setTextColor(xm)term.setBackgroundColor(xb)term.setCursorPos(us-1,cs-fs)if
- zs then term.setBackgroundColor(colors[bs])end if zs then
- term.write(string.rep("\x83",ms+1))term.setTextColor(xb)term.setBackgroundColor(xm)else
- term.write("\159"..string.rep("\143",ms-1))term.setTextColor(xb)term.setBackgroundColor(xm)term.write("\144")end
- if zs then term.setBackgroundColor(colors[bs])end
- term.setCursorPos(us-1,cs+fs)if zs then term.write(string.rep("\x8c",ms+1))else
- term.write("\130"..string.rep("\131",ms-1).."\129")end for Ts=0,fs*2-2 do if
- not zs then term.setTextColor(xm)term.setBackgroundColor(xb)end
- term.setCursorPos(us-1,cs+Ts-fs+1)if zs then
- term.setBackgroundColor(colors[bs])end
- term.write("\x95")term.setCursorPos(us-2+(ms+1),cs+Ts-fs+1)if not zs then
- term.setTextColor(xb)term.setBackgroundColor(xm)end term.write("\x95")end end
- if xs~=false then Es()else t.fill(us-1,cs-fs,ms,fs*2)end local As=ws/ys*ms
- local Os=ws/ys*fs local Is=math.ceil(Os)local Ns=Is*2-2 local Ss=cs+fs
- term.setBackgroundColor(colors[vs])if ks==false or ks==nil then
- t.fill(us,cs-fs+1,As-1,fs*2-1)else t.fill(us,Ss-1-Ns,ms-1,Ns+1)end if gs==true
- then term.setCursorPos(us,cs)term.setTextColor(colors[bs])if ks==true then if
- js then if ws>=ys/2 then term.setBackgroundColor(colors[vs])else
- term.setBackgroundColor(colors[ps])end else if ws>=ys/2-ys/fs then
- term.setBackgroundColor(colors[vs])else term.setBackgroundColor(colors[ps])end
- end elseif ks==false then
- term.setCursorPos(us,cs)term.setTextColor(colors[bs])if ks==true then if ws>=1
- then term.setBackgroundColor(colors[vs])else
- term.setBackgroundColor(colors[ps])end end end if js then
- term.write(ws.."/"..ys)term.setCursorPos(us,cs+1)term.write(qs)else
- term.write(ws.."/"..ys.." "..qs)end
- term.setBackgroundColor(oldcol)term.setTextColor(oldcol1)end
- term.setTextColor(oldcol1)term.setBackgroundColor(oldcol)end end function
- t.frame(Hs,Rs,Ds,Ls,Us,Cs,Ms)a(1,Hs,"number")a(2,Rs,"number")a(3,Ds,"number")a(4,Ls,"number")a(5,Us,"string")a(6,Cs,"string")a(7,Ms,"boolean","nil")local
- Fs=term.getBackgroundColor()local
- Ws=term.getTextColor()term.setBackgroundColor(colors[Cs])t.fill(Hs-1,Rs-Ls,Ds,Ls*2)term.setBackgroundColor(Fs)xm=term.getBackgroundColor()xb=term.getTextColor()term.setTextColor(xm)term.setBackgroundColor(xb)term.setCursorPos(Hs-1,Rs-Ls)if
- Ms then
- term.setBackgroundColor(colors[Us])term.setTextColor(Fs)term.write(string.rep("\x83",Ds+1))term.setTextColor(xb)term.setBackgroundColor(xm)else
- term.setTextColor(Fs)term.setBackgroundColor(colors[Us])term.write("\159"..string.rep("\143",Ds-1))term.setTextColor(colors[Us])term.setBackgroundColor(Fs)term.write("\144")end
- term.setCursorPos(Hs-1,Rs+Ls)if Ms then
- term.setBackgroundColor(Fs)term.setTextColor(colors[Us])term.write(string.rep("\x8f",Ds+1))term.setBackgroundColor(colors[Cs])term.setTextColor(colors[Us])else
- term.write("\130"..string.rep("\131",Ds-1).."\129")end for Ys=0,Ls*2-2 do if
- not Ms then term.setTextColor(xm)term.setBackgroundColor(xb)end
- term.setCursorPos(Hs-1,Rs+Ys-Ls+1)if Ms then
- term.setBackgroundColor(colors[Us])end
- term.setBackgroundColor(colors[Us])term.write("\x95")term.setCursorPos(Hs-2+(Ds+1),Rs+Ys-Ls+1)if
- not Ms then term.setTextColor(xb)term.setBackgroundColor(xm)end
- term.setTextColor(colors[Us])term.write("\x95")end
- term.setBackgroundColor(Fs)term.setTextColor(Ws)end
- return{monitor=e,terminal=t}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement