Advertisement
King0fGamesYami

Stitch Minified

Mar 25th, 2016
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.26 KB | None | 0 0
  1. local a=shell and{}or getfenv()local b,c,unpack=string.sub,string.rep,unpack or table.unpack;local d,e,f,g,h,i,j,k,l,m=1,1,colors.white,colors.black,{},{},{},{},{},{{}},{{}}local n,o={},true;local p=" "local q={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local function r()if not o then return end;local s=1;for t=1,#l do local u,v=1,m[t][1][2]for w=1,#l[t]do local x=l[t][w]local y=m[t][w][1]for t=s,s+v do if h[t]then x.setCursorPos(1,t-s+1)x.blit(b(i[t],u,u+y),b(j[t],u,u+y),b(k[t],u,u+y))end end;u=u+y end;s=s+v end;h={}end;a.write=function(z)sText=tostring(z)local A=#sText;a.blit(sText,c(q[f],A),c(q[g],A))end;a.blit=function(z,B,C)local D=#z;if not i[e]or d+D<1 then return end;local E,F=a.getSize()local G,H=d-1,d+D;local I,J=2-d,E-d+1;if d<1 and E<d+D then i[e]=b(z,I,J)j[e]=b(B,I,J)k[e]=b(C,I,J)elseif d<1 then i[e]=b(z,I)..b(i[e],H)j[e]=b(B,I)..b(j[e],H)k[e]=b(C,I)..b(k[e],H)elseif E<d+D then i[e]=b(i[e],1,G)..b(z,1,J)j[e]=b(j[e],1,G)..b(B,1,J)k[e]=b(k[e],1,G)..b(C,1,J)else i[e]=b(i[e],1,G)..z..b(i[e],H)j[e]=b(j[e],1,G)..B..b(j[e],H)k[e]=b(k[e],1,G)..C..b(k[e],H)end;h[e]=true end;a.clear=function()local E,F=a.getSize()local K,L,M=c(p,E),c(q[f],E),c(q[g],E)for t=1,F do i[t]=K;j[t]=L;k[t]=M;h[t]=true end end;a.clearLine=function()local E,F=a.getSize()i[e]=c(p,E)j[e]=c(q[f],E)k[e]=c(q[g],E)h[e]=true end;a.getCursorPos=function()return d,e end;a.setCursorPos=function(w,t)d,e=w,t end;a.setCursorBlink=function(N)for t,O in ipairs(l)do for w,x in ipairs(O)do x.setCursorBlink(N)end end end;a.isColor=function()for t,O in ipairs(l)do for w,x in ipairs(O)do if not x.isColor()then return false end end end;return true end;a.isColour=a.isColor;a.getSize=function()local E,F=0,0;for t,O in ipairs(m)do F=F+O[1][2]end;for w,x in ipairs(m[1])do E=E+x[1]end;return E,F end;a.scroll=function(P)local Q,R,S={},{},{}local E,F=a.getSize()for T=1,F do Q[T]=i[T-P]or c(p,E)R[T]=i[T-P]or q[f]:rep(E)S[T]=i[T-P]or q[g]:rep(E)h[T]=true end;i,j,k=Q,R,S end;a.setTextColor=function(U)f=U end;a.setTextColour=a.setTextColor;a.getTextColor=function()return f end;a.getTextColour=a.getTextColor;a.setBackgroundColor=function(U)g=U end;a.setBackgroundColour=a.setBackgroundColor;a.getBackgroundColor=function()return g end;a.getBackgroundColour=a.getBackgroundColor;a.setTextScale=function(V)for t,O in ipairs(l)do m[t]=m[t]or{}for w,x in ipairs(O)do x.setTextScale(V)m[t][w]={x.getSize()}end end end;a.setMonitors=function(W)l={}for t,O in ipairs(W)do l[t]=l[t]or{}for w,X in ipairs(O)do l[t][w]=peripheral.wrap(X)l[t][w].name=X;n[X]=true end end;a.setTextScale(1)a.clear()end;local function Y(Z,_,a0)local a1=0;for t,O in ipairs(l)do local a2=0;for w,x in ipairs(O)do if x.name==Z then return _+a2,a0+a1 end;a2=a2+m[t][w][1]end;a1=a1+m[t][1][2]end end;local a3,a4,a5=coroutine.yield,os.startTimer(0.5),true;_G.coroutine.yield=function(...)local a6={a3(...)}if a5 and a6[1]=="timer"and a6[2]==a4 then a4=os.startTimer(0.05)r()elseif a6[1]=="monitor_touch"and n[a6[2]]then return"monitor_touch","stitch",Y(a6[2],a6[3],a6[4])end;return unpack(a6)end;a.disableAutoBuffer=function()a5=false end;a.buffer=function()r()end;a.setVisible=function(a7)if a7 and not o then a.redraw()end;o=a7 end;a.redraw=function()if not o then return end;local E,F=a.getSize()for t=1,F do h[t]=true end;r()end;local a8,a9,aa,ab,ac,ad,ae,af=peripheral.isPresent,peripheral.getType,peripheral.getMethods,peripheral.call,peripheral.wrap,peripheral.find,peripheral.getNames,{}for ag,ah in pairs(a)do af[#af+1]=ag end;peripheral.isPresent=function(ai)return a8(ai)or ai=="stitch"end;peripheral.getType=function(ai)return a9(ai)or ai=="stitch"and"monitor"end;peripheral.getMethods=function(ai)return aa(ai)or ai=="stitch"and af end;peripheral.call=function(ai,aj,...)if ai=="stitch"then return a[aj](...)end;return ab(ai,aj,...)end;peripheral.wrap=function(ai)return ac(ai)or a and ai=="stitch"end;peripheral.find=function(ak,al)if ak=="monitor"then local am=ad(ak,al)am[#am+1]=al and al("stitch",a)or a;return unpack(am)end;return ad(ak,al)end;peripheral.getNames=function()local am=ae()am[#am+1]="stitch"return am end;return a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement