ADADADDDADDDADDADDDDDDDDDDDDDDDDDDADADD1CDADDDDDDDDDDDDDDDDDDDDDDDDDDD4ADAADADADDADDAA1CAADADADADAA1CAAAADD4ADDADDDADDD13CDAD133CDDADD1CDAD1CAAA4333DDDDDD31ADDADD1CDADADADAAAADADA4AAD4CDADADADADAD1CDAAAAAAAADADADADADDADD1CDAD13CAAAAAA4ADDAAAAADADADADDDDDDDDDDDDDD4DADADADADADADADADAAAAAA1CDADDADDADDADADADADADAD1DADADADADDDDDDDCDDADDAAAAAAADADDDDDDDDDAAADDADD43CDADAAADAD13AADD3ADDDADDDADDADD133DADDAD313AADAADDD3DDADDADD133ADADADAD13DD4AADAADDDAAAA11CACAAA1AAAADDDDDDDD1ADADADDADD1CDAD1CADADA4AAAADDDDDDDDD43CDAD1DDDDDDDDDCDADA4A1CDDADDAD4ADADADADADDDDDCDDADD1CDADADADADDADDADDADDAD4ADADADDDDDDDCDAD1CA1CDDADDAD4ADADADADADDDDDCDDADD1CDADADADADADADADADADADDADD1CAAAAAAAAAAAADADADADDDDD4ADADADADADADADADAAAAAAAAAADDDDDDDDDDDDDDDDD433DDDDDDDDDDDDDCDDADDADDADDADDADDADDADDADDADDAD4ADDD4DDD4DDDDDCDADADADADDADDAD4ADADADAADDDD3CAAAADDADDADDADDADDADDAD4ADDD4DDD4DDDDDCDAD1CDAD13CAAAAAA4ADDDDDDAD4ADADDADDADDADD133ADADDDDDDDDDDDD4DDD333ADDADDADDADDADDADD1331CDADDADDADD1CDA31DADADDDDDDDDDDDDDDDD3333DD4DDDDDDD4D3ADADADDADDADDADD1331CDADADADADAD13ADDADDADDADDADDADD133AAADADADAD13ADADADDADDADDADD1331CDADADADADAD13AAADADADAD13DDDD4`f ```ff`f`ffffffffff```f ff`ffffff`f ff```ffffffffff``fff`` ``fffff fffff f f fffffffffffffff f f fffffffffffffff f f fffffffffffffff f f ffffffffff """"""""""""""""""33""33""33""33""33""33""33""333333333333333333 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUffffffffffffffffffffffffffffffffwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww fff`ffff`ff`fffffff`f`ffffff`ff ff`f f`f f fffff ` f ` f f f3333#""#""#""#""#""#""t""((""ff`````ݍ0 3=3 30ݍ   0" 0# 03 0    "" "" ЈЈЈЈЈЈݍЈ ЈݍݍЈ 3 0  3Јݍ݈ݍЈ Јݍ  @D   NO DD DD     0231"!3333330303 "!33333303ލ莈؍!!!!rwwqww'rww!!!! >>  ADD!"" ADD"""""ADDD1CDD!"""""AADDDADD"""""AADDDDDDDDDDD$"""""ADAAD1CADDDDDDDDDDD,""""ADAADAADDDDDDDDDDDD-,""ADD1CADAADDDDDDDDDDDD,","ADDAADAADD43CDD4333-"-"AD4CAADAADDADD"""""ADAAADAADDD1CDD!",ADAAADDAADDDADD""ADAAADDA13CD1CD!""DADAA1CDA4ADAD""""LDADAAADA13AD$""""D4AD1CAD13CDAD,""""BDADAADADA,"""ADADAADADA,""ADADAADAD,""ADAADAADAD,"ADAADAADAD,"AD1CDDADDDAD,ADADDADDDAD!-ADDADD1CDDADD",ADDADDADDADD!",ADDDADDADDAD4""ADDDADDADDAD!""133313313313"""""ADD!"""""ADD"""""A43CD!,""ADDDAADDADDAADDAAAD",""BADDDAADDADDAADDAA1CD!"-""1CDDDDD1CDDDDADDD1CDDDDAD1CAAD"""""ADDDDDADDDDADDDADDDDADA1CAD!""AD43CDDAD4CDDADDDDAD4CDDADAAAD"""LADADDADADDADDDDADADDADA1AD!""4AD1CDAD1CDAD4CDAD1CDADAAD"""LADADADADADADADADADAAD$"""DADA4ADADAD1CADADADDAAD,""""BDADAADADADAADADADDAA,""""ADADDDDDDADDDD4ADAADDDD41CDA4A,"""ADADDDDDDADDDDADAADDDDADA,"""ADADDDDDDDADDD4ADDDDADDD413CD,""ADADDDDDDDADDDADDDDADDDAD-""ADAD433CDDADDDDAD43CADDDDAD,""ADADADDADDDDADAADDDDAD!,""ADAADADDAD4CDADAAD4CDAD","ADAADADDADADADAADADAD!-"ADADD1CDDADD4AD1CDADDAAD1CDAD","ADADDADDADDADADADDAADADAD!"DDDADDDADDDDDDDADDADADDADADDADADD""LDDDADDDADDDDDDDADDADADDADADDADADD "DDD4ADDD1CDDDDD4ADDADADDADADDADAD4""LDDDADDDADDDDDADDADADDADADDADAD "3333133313333313313133131331313""" """                                      %-- title: Tiny Library: ShowCase -- author: DuckAfire -- desc: A showcase of all resources available in TinyLibrary -- license: MIT -- site: duckafire.github.io/nest -- version: 2.10.2 -- script: lua -- saveid: tiny_library_save_id --==============================================================================-- -- Tiny Library: ShowCase -- Copyright (c) 2024 DuckAfire -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. --==============================================================================-- -- TinyLibrary -- Copyright (C) 2024 DuckAfire -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. local TL1, TL2, TL3, TL4 = {}, {}, {}, {} do local T63,E3,TU6,MS22,F33,M42,T21,MM12,MM14,M43,MA0=trace,error,table.unpack,math.sqrt,fget,mget,type,math.max,math.min,mouse,math.abs local function libError(a,b,c,d,e,f)if a~=nil then if not a then return end end local g={"Error","Function","Index"}local h={nil,e,"#"..f}local i="\n\n[coli2DA]"b=b and'"'..b..'" ' or"" local function j(k)h[1]=b..k end if c=="1" then j("was not specified")elseif c=="2" then j("was not defined")elseif c=="3" then j("is invalid")else j(c)end for l=1,3 do i=i.."\n"..g[l]..": "..h[l].."." if l==1 and d~=nil then i=i.."\nTry: " for m=1,#d-1 do i=i..d[l].." | " end i=i..d[#d]end end T63("\n>\n>\n>")E3(i.."\n")end local RE="rect" local CI="circ" local SI="simp" local W="width" local H="height" local R="radius" local ByBd=1 local OrgBd={"newBody","distance","mapAlign","tile","tileCross","rectangle","circle","shapesMix","impactPixel"} TL1.newBody=function(a,b,c,d,e)local f=nil if a==RE then f={x=b,y=c,width=d or 8,height=e or 8}elseif a==CI then f={x=b,y=c,radius=d or 4}elseif a==SI then f={x=b,y=c}end libError(f==nil,"type","3",{RE,CI,SI},OrgBd[ByBd],1)local g={"x","y"}for h=1,2 do libError(f[g[h]]==nil,g[h],"3",nil,OrgBd[ByBd],1+h)end return f end local function ckbd(a,b,c) ByBd=c local d,e,f d={}e={"x","y","width","height"}f={[RE]=4,[CI]=3,[SI]=2}for g=1,#a do d[g]={}for h=1,f[b[g]]do if b[g]==CI and h==3 and a[g][R]~=nil then d[g][h]=a[g][R]else d[g][h]=a[g][e[h]]or a[g][h]end end end local i={}for g=1,#a do i[g]=TL1.newBody(b[g],d[g].x or d[g][1],d[g].y or d[g][2],d[g][W]or d[g][R]or d[g][3],d[g][H]or d[g][4])end ByBd=1 return TU6(i) end TL1.distance=function(a,b)a,b=ckbd({a,b},{SI,SI},2)return MS22((a.x-b.x)^2+(a.y-b.y)^2) end TL1.mapAlign=function(a,b)a=ckbd({a},{(b)and RE or SI},3)if b then a[W]=a[W]or 8 a[H]=a[H]or 8 a.x=a.x+a[W]//2 a.y=a.y+a[H]//2 end return(a.x//8)*8,(a.y//8)*8 end TL1.tile=function(a,b,c,d,e)a=ckbd({a},{RE},4)d=d or 0 e=e or 0 local f,g,h,i local j,k=a[W],a[H]if b=="top" then f,g,h,i=0,-1,j-1,-1 elseif b=="bottom" then f,g,h,i=0,k,j-1,k elseif b=="left" then f,g,h,i=-1,0,-1,k-1 elseif b=="right" then f,g,h,i=j,0,j,k-1 else libError(nil,"type","3",{"top","bottom","left","right"},"tile","(last)")end return F33(M42((a.x+f)//8+d,(a.y+g)//8+e),c)and F33(M42((a.x+h)//8+d,(a.y+i)//8+e),c)end TL1.tileCross=function(a,b,c,d,e)a=ckbd({a},{RE},5)local f={}for g=1,4 do f[g]=(T21(c)=="number")and c or(T21(c)~="table")and 0 or c[g]end local h={}local i={"top","bottom","left","right"}for g=1,4 do h[g-1]=TL1.tile(a,i[g],f[g],d,e)end return(b)and{top=h[0],bottom=h[1],left=h[2],right=h[3]}or h end TL1.box360=function(a,b,c,d,e,f)local g=TL1.tileCross(c,false,d,e,f)local h=b and((b<0 and g[0])or(b>0 and g[1]))or false local i=a and((a<0 and g[2])or(a>0 and g[3]))or false return h or i end TL1.rectangle=function(a,b)local c,d={a,b},{W,H}for e=1,2 do for f=3,4 do if not c[e][f]and not c[e][d[f]]then c[e][f]=1 end end end c[1],c[2]=ckbd({c[1],c[2]},{RE,RE},6)return MM12(c[1].x,c[2].x)=a and f.x<=c and f.y+f[H]-1>=b and f.y<=d end TL1.impactPixel=function(a,b,c,d)libError(a~=RE and a~=CI,"type","3",{RE,CI},OrgBd[9],"(first)")b,c=ckbd({b,c},{a,a},9)if a==RE then if not d and not TL1.rectangle(b,c)then return nil,nil end local e={x=b.x+b[W]/2,y=b.y+b[H]/2,[R]=(b[W]+b[H])/2}local f={x=c.x+c[W]/2,y=c.y+c[H]/2,[R]=(c[W]+c[H])/2}return TL1.impactPixel(CI,e,f,true)end if a==CI then if not d and not TL1.circle(b,c)then return nil,nil end local g=(b.x*c[R])+(c.x*b[R])local h=(b.y*c[R])+(c.y*b[R])local i=(b[R]+c[R])return g/i,h/i end end end do local T63,E3,P11,T20,T21,MA0,SF3,T19,SS14,S60=trace,error,print,tostring,type,math.abs,string.find,tonumber,string.sub,spr local function libError(a,b,c,d,e,f)if a~=nil then if not a then return end end local g={"Error","Function","Index"}local h={nil,e,"#"..f}local i="\n\n[print+]"b=b and'"'..b..'" ' or"" local function j(k)h[1]=b..k end if c=="1" then j("was not specified")elseif c=="2" then j("was not defined")elseif c=="3" then j("is invalid")else j(c)end for l=1,3 do i=i.."\n"..g[l]..": "..h[l].."." if l==1 and d~=nil then i=i.."\nTry: " for m=1,#d-1 do i=i..d[l].." | " end i=i..d[#d]end end T63("\n>\n>\n>")E3(i.."\n")end local LenBy=1 local ShaBy=1 TL2.length=function(a,b,c,d)local e={"length","center","pCenter","pShadow","pBorder","pList"}LenBy=1 c=c or 1 return P11(T20(a),0,136,0,b,c,d),5*c end TL2.center=function(a,b,c,d,e,f)if LenBy<2 then LenBy=2 end local g,h=TL2.length(a,d,e,f)return(b or 0)-g//2+1,(c or 0)-h//2 end TL2.pCenter=function(a,b,c,d,e,f,g)LenBy=3 b,c=TL2.center(a,b,c,e,f,g)P11(a,b,c,d,e,f or 1,g)end TL2.pShadow=function(a,b,c,d,e,f,g,h,i)local j=(ShaBy==1)and"pShadow" or"pList" local k={}if T21(b)=="number" then k[1]=b<0 and 0 or b>15 and 15 or MA0(b)k[1]=k[1].."-1" elseif T21(b)=="table" then for l=1,#b do k[l]=b[l]end else libError(nil,"shadow","is not a number or table",nil,j,5)end libError(k[1]==nil,"shadow","values not defined",nil,j,1)if i then LenBy=4 c,d=TL2.center(a,c,d,f,g,h)end g=g or 1 local m,n,o=0,0,0 local p,q,r={},{},{}local s={p,q,r,"color","direction","distance"}local t={[0]={0,-1},{0,1},{-1,0},{1,0}} for l=1,((#k<4)and#k or 4)do for u=1,2 do m=SF3(k[l],'-')if#k[l]==1 and T19(k[l])~=nil then m=0 end libError(m==nil,nil,"Hyphen not specified. In index #"..l..' of the table "shadow"',nil,j,1)if u==1 then p[l]=SS14(k[l],1,m-1) k[l]=SS14(k[l],m+1,#k[l]) else q[l]=SS14(k[l],1,m-1) if m==0 then r[l]=g else r[l]=SS14(k[l],m+1,#k[l]) end end for v=1,3 do if s[v][l]~=nil then s[v][l]=T19(s[v][l])end end end for u=1,3 do libError(T21(T19(s[u][l]))~="number",nil,"The element "..s[u+3]..' is NaN. In index #'..l..' of the table "shadow".',nil,j,1)end for v=2,3 do s[v][l]=(s[v][l]<0)and 0 or(s[v][l]>3)and 3 or s[v][l]end n=c+t[q[l]][1]*r[l]o=d+t[q[l]][2]*r[l]P11(a,n,o,p[l],f,g,h)end P11(a,c,d,e,f,g,h)ShaBy=1 end TL2.pBorder=function(a,b,c,d,e,f,g,h,i,j)local k,l=0,0 local m={{0,-1},{0,1},{-1,0},{1,0}}if j then LenBy=5 b,c=TL2.center(a,b,c,f,g,i)end g=g or 1 n=e or 0 h=h or g for o=1,4 do k=b+m[o][1]*h l=c+m[o][2]*h P11(a,k,l,e,f,g,i)end P11(a,b,c,d,f,g,i)end TL2.pList=function(a,b,c,d,e,f,g,h,i,j,k)libError(T21(a)~="table","text","1",nil,"pList",1)local l={}if T21(d)=="table" then libError(#d<#a,"color","insufficient number of indexes","pList",3)l=d else for m=1,#a do l[m]=d end end b,c=b or 0,c or 0 g=g or 1 e=e or 13*g i=i or-1 if k then libError(T21(k)~="table","effect","3",nil,"pList",10)libError(k[1]~="shadow" and k[1]~="border","effect[1]","3",{"shadow","border"},"pList",10) if k[1]=="shadow" then libError(T21(k[2])~="table" and T21(k[2])~="number","effect[2]","is not a table or number",nil,"pList",10)elseif k[1]=="border" then libError(T21(k[2])~="number","effect[2]","is NaN",nil,"pList",10) end end local n=0 if j or i~=-1 then local o,p=0,0 for m=1,#a do if o<#a[m]then o=#a[m]p=a[m]end end LenBy=6 if j then b=TL2.center(p,b,c-#a,f,g,h)c=c-((#a-1)*e*g)//2 end n=TL2.length(p,f,g,h)end local q,r=0,0 for m=1,#a do q=b r=c+e*(m-1)if i~=-1 then LenBy=6 if i==0 then q=TL2.center(a[m],q+n//2,r,f,g,h)elseif i==1 then q=q+n-TL2.length(a[m],f,g,h)end end if not k then P11(T20(a[m]),q,r,l[m],f,g,h)else if k[1]=="shadow" then ShaBy=2 TL2.pShadow(a[m],k[2],q,r,l[m],f,g,h)elseif k[1]=="border" then TL2.pBorder(a[m],q,r,l[m],k[2],f,g,k[3],h)end end end end TL2.title=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)libError(T21(p)=="table",'"sprites"',"1",nil,"title",1)local q,r,s={},{},0 if T21(i)~="table" then s=i or 0 for t=1,#a do q[t]=s end else q=i end if T21(j)~="table" then s=j or 0 for t=1,#a do r[t]=s end else r=j end local function u(v,w,x)libError(#a>#v,w,"has a insuficient quatity of indexes","title",x)end u(q,"flip",9)u(r,"rotate",10)local y=nil if T21(d)=="number" then y={}for t=1,#a do y[t]=d end elseif T21(d)=="table" then u(d,"chromaKey",4)y=d else y={}for t=1,#a do y[t]=0 end end b,c=b or 0,c or 0 f=f or 1 e=e or 1 n=n or 1 o=o or 1 g=(g or 8)*f h=(h or 8)*f local z,aa=0,0 if k then z=(m)and(g//2)or((g+e)*#a-e)//2 end if l then aa=(m)and(((h+e)*#a-e)//2)or(h//2)end local ab,ac for t=1,#a do if m then ab=b-z ac=c+((h+e)*(t-1))-aa else ab=b+((g+e)*(t-1))-z ac=c-aa end S60(a[t],ab,ac,y[t],f,q[t],r[t],n,o)end end end do local T63,E3,T19,T21,SL8,SU16,SS14,P46,SF4,MF8,P52,SG6=trace,error,tonumber,type,string.lower,string.upper,string.sub,peek,string.format,math.floor,poke,string.gsub local function libError(a,b,c,d,e,f)if a~=nil then if not a then return end end local g={"Error","Function","Index"}local h={nil,e,"#"..f}local i="\n\n[Magic_Palette]"b=b and'"'..b..'" ' or"" local function j(k)h[1]=b..k end if c=="1" then j("was not specified")elseif c=="2" then j("was not defined")elseif c=="3" then j("is invalid")else j(c)end for l=1,3 do i=i.."\n"..g[l]..": "..h[l].."." if l==1 and d~=nil then i=i.."\nTry: " for m=1,#d-1 do i=i..d[l].." | " end i=i..d[#d]end end T63("\n>\n>\n>")E3(i.."\n")end local AD=T19("0x03fc0") TL3.sort=function(a,b,c)local d={}b=b or 0 if T21(a)=="string" then local e=(c)and SL8 or SU16 a=a.."000000" for f=1,5,2 do d[#d+1]=e(SS14(g,f,f+1))end elseif T21(a)=="table" then for f=1,#a do d[f]=a[f]end else libError(nil,"orgCode","3",nil,"sortCode",1)end for f=1,3 do if not d[f]then d[f]=0 end end if b==0 then return d[1],d[2],d[3]end if b==1 then return d end if b==2 then return{red=d[1],green=d[2],blue=d[3]}end if b==3 then if h then return"#"..d[1]..d[2]..d[3]end return d[1]..", "..d[2]..", "..d[3] end libError(nil,"order","3",{"0-3"},"sortCode",2)end TL3.save=function(a,b)local c=(a)and"" or{}local d=0 for e=0,15 do if not a then c[e]={}end for f=0,2 do d=P46(AD+e*3+f) if a then c=c..SF4("%x",d) else c[e][f]=d end end if a and b and e<15 then c=c.."-" end end return c end TL3.toDec=function(a,b)libError(T21(a)~="string","string","1",nil,"toDec",1)a=(SS14(a,1,1)=="#")and SS14(a,2)or a local c,d={},0 for e=0,2 do d=e+1+(e*1)c[e+1]=T19(SS14(a,d,d+1),16)end return f(c,b)end TL3.toHex=function(a,b,c)libError(T21(a)~="table","table","1",nil,"toHex",1)local d="" for e=1,3 do if a[e]<0 then a[e]=0 elseif a[e]>255 then a[e]=255 end d=d..SF4("%x",MF8(a[e]))end return f(d,b,c)end TL3.swap=function(a,b)if SS14(a,1,4)=="000:" then a=SS14(a,5)elseif SS14(a,1,1)=="#" then a=SS14(a,2)end local function c(d,e)local f,b,g=e or 0,0,0 for h=0,2 do b=h+1+(h*1)g=T19(SS14(a,b+f,b+1+f),16)P52(AD+d*3+h,g)end end if b=="palette" then a=SG6(a,"-","")for h=0,15 do c(h,6*h)end return end if b=="equal" then for h=0,15 do c(h)end return end libError(T21(b)~="number","id","3",{"palette","equal","numbers: \"0-15\""},"swap",2)c(T19(b))end TL3.shine=function(a,b,c)local d=0 a=a and MF8(a)or 1 local e,f=0,0 local g,h=0,15 local i,j,k=(T21(c)=="table"),0,255 if b~=nil then libError(b<0 or b>15,"id","3",nil,"shine","2")g=b h=b if i then c={[b]=(T21(c[b])=="table")and c[b]or((T21(c[1])=="table")and c[1]or c)}end end for l=g,h do for m=0,2 do e=P46(AD+l*3+m)if i then j=c[l][m]k=c[l][m]end if a<=0 then f=(e+a>=j)and e+a or j else f=(e+a<=k)and e+a or k end P52(AD+l*3+m,f)if f==j or f==k then d=d+1 end end end if d==((b==nil)and 48 or 3)and MF8(a)~=0 then return(a<0)and-1 or 1 end return 0 end end do local T63,E3,P51,T19,SS14,T20,T21,SF3,TI1=trace,error,pmem,tonumber,string.sub,tostring,type,string.find,table.insert local function libError(a,b,c,d,e,f)if a~=nil then if not a then return end end local g={"Error","Function","Index"}local h={nil,e,"#"..f}local i="\n\n[longBit]"b=b and'"'..b..'" ' or"" local function j(k)h[1]=b..k end if c=="1" then j("was not specified")elseif c=="2" then j("was not defined")elseif c=="3" then j("is invalid")else j(c)end for l=1,3 do i=i.."\n"..g[l]..": "..h[l].."." if l==1 and d~=nil then i=i.."\nTry: " for m=1,#d-1 do i=i..d[l].." | " end i=i..d[#d]end end T63("\n>\n>\n>")E3(i.."\n")end local ZERO=2000000000 local MAX=2999999999 local LBC={} local CID={} local Origin={"getNum","getBool","setNum","setAll","update"}local GetBy=1 local SetBy=3 local AllBy=4 local function classToId(a,b,c)for d=1,#CID do if a==LBC[CID[d]]then return CID[d]end end libError(nil,nil,"Invalid class ("..a..")",nil,b,c)end local function ckSign(a,b,c)libError(a<0,nil,"It is not possible store negative values",nil,b,c)end local function ckId(a,b,c,d)a=(d~=2)and a or classToId(a,b,c)libError(a<0 or a>((d==1)and 255 or 9),"Index","3",nil,b,c)end local function ckDf(a,b,c)libError(P51(a)MAX,nil,"Memory not defined or invalid",nil,b,c)end local function ckGet(a,b,c,d)b=b or 1 libError(b<=0,"length","3",nil,c,d+2)local e={a+1,a+1+b-1}for f=1,2 do libError(e[f]<2-1*(f-1)or e[f]>10,((f==1)and"index" or"length"),"3",nil,c,d+2*(f-1))end return e[1],e[2] end TL4.getNum=function(a,b,c)ckId(a,Origin[GetBy],1,0)local d=classToId(b,"getNum",2)a,c=ckGet(a,c,Origin[GetBy],1)GetBy=1 return T19(SS14(T20(P51(d)),a,c))end TL4.getBool=function(a,b,c,d)GetBy=2 return TL4.getNum(a,b,d)==(c or 1)end TL4.getClass=function(a)ckId(a,"getClass",1,1)return LBC[a]end TL4.getAll=function(a,b)local c=classToId(a,"getAll",1)ckDf(c,"getAll",1)local d=SS14(T20(P51(c)),2)if b then return d end return T20(T19(d)) end TL4.setClass=function(a,b,c)c=c or 0 libError(T21(a)~="table","classes","1",nil,"setClass",1)local d=c+#a-1 libError(d>255,nil,"Index overflow (init + #classes - 1 > 255)",nil,"setClass",1)local e=1 local f=1 local g=false local h=false for i=c,d do libError(a[e]=="" or SF3(a[e]," ")~=nil,nil,"Invalid class. Do not use void strings or strings with spaces",nil,"setClass",1)h=(LBC[i]~=nil)if not h or b then LBC[i]=a[e] f=f+1 end e=e+1 g=true if not h then for j=1,#CID do if CID[j]==i then g=false break end end end if g then TI1(CID,i)end end return(#a==f)end TL4.setNum=function(a,b,c,d)local e,f="",0 b,d=ckGet(b,d,Origin[SetBy],2)if T21(a)=="boolean" then g=(a)and 1 or 0 else g=T20(a)local h=(d+1)-b if h>1 then for i=1,h do if#g10^h,nil,"Sub-memory OVERFLOW",nil,Origin[SetBy],1)end ckSign(f,Origin[SetBy],1)local j=classToId(c,Origin[SetBy],3)local function k(l,m)return SS14(T20(P51(j)),l,m)end local n=k(1,b-1)local o=k(d+1)SetBy=3 P51(j,T19(n..g..o))end TL4.setAll=function(a,b,c,d)if not c then ckSign(a,Origin[AllBy],1)end local e=classToId(b,Origin[AllBy],2)if c then a=P51(e)+a else a=T20(a) if#a<9 then for f=1,9-#a do a="0"..a end end a=T19("2"..a)end local g=(aMAX)and 1 or 0 if h then if g<0 then P51(e,ZERO) elseif g>0 then P51(e,MAX) else P51(e,a) end else libError(g<0,nil,"[ UNDERFLOW ]",nil,"setAll",1)libError(g>0,nil,"[ OVERFLOW ]",nil,"setAll",1)P51(e,a)end AllBy=4 return g end TL4.boot=function(a,b,c,d,e)c=c or 0 e=(T19(e)~=nil)and e or 0 local f,g,h=0,"",0 ckId(c,"boot",3,1)ckId(e,"boot",5,0) local i=c+#a-1 libError(#a>256,nil,"The table specified is bigger that 256",nil,"boot",1)libError(i>255,nil,"Index overflow (init + #items - 1 > 255)",nil,"boot",1)for j=c,i do f=f+1 if P51(j)<=ZERO or b then g=a[f]h=T19(g)ckSign(h,"boot",1)libError(T21(g)~="string",nil,g.." is not a string",nil,"boot",1)libError(T19(h)==nil,nil,g.." cannot be converted to number",nil,"boot",1)libError(T19(h)>MAX,nil,g.." is too large (max: "..MAX..")",nil,"boot",1)while#g<9 do g=(d)and e..g or g..e end P51(j,T19("2"..g))end end return(#a==f)end TL4.update=function(a,b,c)ckDf(classToId(a,"update",2),"update",2)local d={#b,#c,'"values"','"indexes"'}for e=1,2 do libError(d[e]<1 or d[e]>9,d[e+2],"invalid quantity of indexes",{"(min: 1","max: 9)"},"update",1+e)end libError(#b~=#c,nil,"The quantity of values and indexes must be equal",nil,"update","2-3")GetBy,SetBy=5,5 local f,g,h="",0,0 for e=1,#c do f="values["..e.."] is not a "g=T19(b[e])libError(T21(b[e])~="string",nil,f.."string",nil,"update",1)libError(g==nil,nil,f.."number",nil,"update",1)if TL4.getNum(c[e],a,#b[e])~=g then TL4.setNum(g,c[e],a,#b[e])h=h+1 end end return h end TL4.clear=function(a,b,c,d)local e=false local f={"all","memory","class","noMemory","noClass"}for g=1,#f do if a==f[g]then e=true break end end libError(not e,"type","3",f,"clear",1)c=c or 0 d=d or 255 ckId(c,"clear",3,0) ckId(d,"clear",4,1) local h,i=false,0 local function j()i,h=i+1,true end local k=(b)and 0 or ZERO if a=="memory" or a=="all" then for g=c,d do P51(g,k)j()end end if a=="class" or a=="all" then for g=#CID,1,-1 do if CID[g]>=c and CID[g]<=d then LBC[CID[g]]=nil CID[g]=nil j()end end return h end if a=="noClass" then for g=c,d do if LBC[g]==nil then P51(g,k)j()end end return h end if a=="noMemory" then local l=0 for g=#CID,1,-1 do l=CID[g]if l>=c and l<=d and(P51(l)MAX)then LBC[l]=nil CID[g]=nil j()end end return h,i end end TL4.swapClass=function(a,b)local function c(d,e,f)libError(T21(d)~="string",e,"3",nil,"swapClass",f)end c(a,"newName",1)c(b,"oldName",2)LBC[classToId(b,"swapClass",2)]=a end end local coli, plus, mpal, lbit = TL1, TL2, TL3, TL4 --==============================================================================-- local INFO = [[ ==================== GENERAL INFORMATIONS ==================== >>>>>>>>>>>>>>>>>> Name:.......................TinyLibrary <<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>> Version:..................v4.0.0 (A new face) <<<<<<<<< >>>>>>>>>>>>>>>>>> Script:....................Lua 5.3 <<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>> License:..................Zlib .<<<<<<<<<<<<<<<<<<<<< TinyLibrary Copyright (c) 2024 DuckAfire Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >>>>>>>>>>>>>>>>>> Libraries:..................x4 .<<<<<<<<<<<<<<<<<<<<< ~~~~~~~~~~~~~~~~~~ coli2DA...................v4.0.3 ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ print+.....................v4.3.2 ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ Magic_Palette.......v2.1.1 ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ longBit...................v3.5.3 ~~~~~~~~~~~~~~~~~~~~ ============================================================================== ]] local SHOW = { { "box360( spdX, spdY, rect, flag=0, mapX=0, mapY=0 )", "circle( body, circ )", "distance( xy1, xy2 )", "impactPixel( body1, body2, force=false )", "mapAlign( body, onCenter=false )", "newBody( type, x, y, width/radius=8/4, height=8 )", "rectangle( body, rect )", "shapesMix( circ, rect )", "tile( obj, type, flag=0, mapX=0, mapY=0 )", "tileCross( obj, associative=false, flag=0, mapX=0, mapY=0 )", "touch( initX, finalX, initY, finalY, cursorDim={0, 0} )", }, { "center( text, x=0, y=0, fixed=false, scale=1, smallfont=false, lines=1 )", "length( text, fixed=false, scale=1, smallfont=false, lines=1 )", "pBorder( text, x=0, y=0, color=0, bcolor=0, fixed=false, scale=1, distance=scale, smallfont=false, onCenter=false )", "pCenter( text, x=0, y=0, color=0, fixed=false, scale=1, smallfont=false, lines=1 )", "pList( text, x=0, y=0, color=0, space=13, fixed=false, scale=1, smallfont=false, align=-1, onCenter=false, effect=nil )", "pShadow( text, shadow, x=0, y=0, color=0, fixed=false, scale=1, smallfont=false )", "title( sprites, x=0, y=0, chromaKey=0, space=1, scale=1, width=8, height=8, flip=0, rotate=0, alignX=false, alignY=false, vertical=false, sprWid=1, sprHei=1 )", }, { "save( hex=false, hyphen=false )", "sort( code, order=0, low=false )", "shine(,, speed,, id=nil,, original=nil )", "swap( code, id )", "toDec( code, order=0 )", "toHex( code, order=0, low=false )", }, { "boot( values, force=false, init=0, left=false, empty=0 )", "clear( type, absolute=false, init=0, max=255 )", "getAll( class, full=false )", "getBool( id, class, equal=1, length=1 )", "getClass( id )", "getNum( id, class, length=1 )", "update( mode, class, values/[sValue=0], indexes/[sIndex=1] )", "setAll( value, class, update=false )", "setClass( classes, init=0 )", "setNum( value, id, class, length=1 )", "swapClass( newClass, id )", } } local LINK = { {"> Repository:", "> github.com/duckafire/TinyLibrary", 10}, {"> Wiki:", "> github.com/duckafire/TinyLibrary/wiki", 6}, {"> Download:", "> github.com/duckafire/TinyLibrary/releases/latest", 4} } -- HEAD -- cursor local mx, my, mp, ms, mq = 0, 0, false, 0 local Tap, Mspt = false, {144, 160, 1} -- other local Menu = 0 local ShineX, ShineMax = 242, math.random(250, 350) local CurLib, CurFunc = 1, 1 local BorderColor = 0 local AbovePopup = false local UpBorderColor = false -- menu local InfoY = 0 -- info local InfoDif = nil local CopyTimer = 0 -- link local HelpMsg = 300 -- help message local MsgTimer = {0, 0} -- view object to coli2da local OBJ = {{}, {}} for i = 1, 2 do OBJ[i] = { x = 0, y = 0, spdX = 0, spdY = 0, width = 0, height = 0, radius = 0, automove = false, cursorPoint = false, } end local ModeSwapped = false local FuncMode, ObjID = 0, 1 -- popup (coli2DA) local pop = {X = 100, Y = 100, id = 0, switch = {{}}, x = nil, y = nil, w = nil, h = nil} for i = 1, 16 do pop.switch[1][i] = 0 end function pop:gID() self.id = self.id + 1 return math.ceil(pop.switch[1][self.id]) end -- update index of the buttons function pop:xy(a, b) self.x, self.y = self.X + a, self.Y + b end -- cursor position based in popup position function pop:gStt(id) return self.switch[1][id] == 1 end -- get state of switch function pop:onOff(bool) if bool then return false end return true end -- invert boolean value -- panel (Magic_Palette) local PalSaved = nil local PalSavedHex = "" local PalId = 1 local PalShine = false local PalShineSpd = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} local PalToDefault = false local function clearPalette() if mpal.save(true) ~= PalSavedHex then PalId = 1 PalShine = false PalToDefault = false UpBorderColor = true mpal.swap("1A1C2C5D275DB13E53EF7D57FFCD75A7F07038B76425717929366F3B5DC941A6F673EFF7F4F4F494B0C2566C86333C57", "palette") return true end return false end -- items (longBit) local MemID = 1 local SubMemID = 1 local SubMemLen = 1 local function toClass(n) return string.format("%c", n + 96) end local function memTitle() rect(121, 24, 118, 12, 15) plus.pCenter("< Pmem #"..MemID.." >", 180, 30, 12, false, 2) end local function memPop(x, y, id, str) for i = 1, 2 do if i ~= 1 then x = x + 57 spr(238, x - 11, y + 5, 0) -- arrow end if i ~= hide then rect( x, y, 43, 9, 15) rectb(x, y, 43, 17, 14) line(x + 1, y + 8, x + 41, y + 8, 14) print("PMEM #"..id, x + 2, y + 2, 12) print(str[i], x + 2, y + 10, 13, false, 1, true) end end end local function memBtn(txt, w) local c1, c2 = 14, 15 if coli.touch(122, 125, 122 + w - 1, 133) then c1, c2 = 12, 13 end rectb(122, 125, w, 9, c1) print(txt, 124, 127, c2) end -- values local function getObjId(...) local ids = {...} for i = 1, #ids do if CurFunc == ids[i] then return true end end return false end local function setObjPos(tblID, i) local adj, pos = 1 * (i - 1), nil local ix, iy = i + adj, i + 1 + adj pos = {{180, 68, 180, 68}, {170, 38, 170, 78}, {176, 64, 0, 0}, {180, 48, 170, 78}, {123, 3, 170, 58}} OBJ[i].x = pos[tblID][ix] OBJ[i].y = pos[tblID][iy] end local function defaultValues(force) if CurLib == 1 or force then for i = 1, 2 do if getObjId(2, 3) then setObjPos(1, i) -- circle, distance elseif getObjId(4, 7) then setObjPos(2, i) -- rectangle elseif getObjId(1, 5, 9, 10) then setObjPos(3, i) -- box360, tile, tileCross elseif getObjId(8) then setObjPos(4, i) -- impactPixel, shapesMix elseif getObjId(11) then setObjPos(5, i) -- touch end OBJ[i].automove, OBJ[i].cursorPoint = false, false OBJ[i].spdX, OBJ[i].spdY = nil, nil OBJ[i].width, OBJ[i].height, OBJ[i].radius = 20, 20, 10 end ObjID = 1 FuncMode = 0 UsingCursor = getObjId(2, 3, 4, 7, 8, 11) if not force then return end end if clearPalette() then return end if CurLib == 4 or force then MemID = 1 SubMemID = 1 SubMemLen = 1 return end end -- general local function insArea(a, b, c, d, isRect, reverse) local id = (reverse) and ((ObjID == 1) and 2 or 1) or ObjID local nx, ny = OBJ[id].x, OBJ[id].y local A, C = 121 + a, 238 + c local B, D = 1 + b, 134 + d -- cursor outside 'area' if isRect then nx = (nx < 121) and 121 or (nx + c > 239) and 239 - c or nx ny = (ny < 1) and 1 or (ny + d > 135) and 135 - d or ny else nx = (nx - a < 121) and A or (nx - c > 238) and C or nx ny = (ny - b < 1) and B or (ny - d > 134) and D or ny end if reverse then return nx, ny end -- cursor inside 'area' if not AbovePopup and not OBJ[ObjID].automove and coli.touch(121, 1, 238, 134) then if isRect then if mx >= 121 and mx <= 239 - c then nx = mx elseif mx + c > 239 then nx = 239 - c end if my >= 1 and my <= 135 - d then ny = my elseif my + d > 135 then ny = 135 - d end else if mx >= A and mx <= C then nx = mx else nx = (mx < 180) and A or C end if my >= B and my <= D then ny = my else ny = (my < 68) and B or D end end end return nx, ny end -- help messages local function msgAnimText(text) local x, y = mx + 5, my - 2 local w = plus.length(text[1], false, 1, true) rect( x, y, w + 3, 21, 0) rectb(x, y, w + 3, 21, 12) plus.pList(text, x + 2, y + 2, 4, 6, false, 1, true) end local function msgAnim(hitbox, info, onlyExit) local x, y = 107, 50 local x2, y2 = x - 4, y + 25 x = x + 4 * info if HelpMsg <= 0 then return end if hitbox then return coli.touch(x - 2, y - 2, x + 29, y + 14) or coli.touch(x2 - 2, y2 - 2, x2 + 37, y2 + 15) end HelpMsg = HelpMsg - 1 MsgTimer[1] = MsgTimer[1] + 0.035 if MsgTimer[1] > ((info == 1) and 5 or 9) then MsgTimer[1] = 0 end -- exit message MsgTimer[2] = MsgTimer[2] + 0.035 if MsgTimer[2] > 2 then MsgTimer[2] = 0 end rect( x2 - 2, y2 - 2, 40, 18, 0) rectb(x2 - 2, y2 - 2, 40, 18, 12) for i = 0, 1 do -- mouse btn2 spr(368 + math.floor(MsgTimer[2]) + 2 * i, x2 + 16 * i, y2 + 2 * i, 0, 2) -- screen board if i == 1 then spr(336 - 12 * math.floor(MsgTimer[2]), x2 + 22, y2, 0, 2) end end if coli.touch(x2 - 2, y2 - 2, x2 + 37, y2 + 15) then msgAnimText({"Use to come back:", "> Mouse right", "> Click in border"}) end if onlyExit then return end -- navigate "tutorial" rect( x - 2, y - 2, 32 - 9 * info, 17 + info, 0) rectb(x - 2, y - 2, 32 - 9 * info, 17 + info, 12) if info == 1 then -- mouse btn2 spr(((MsgTimer[1] < 2) and 320 or 322), x, y, 0, 2) -- cursor/touch spr(((MsgTimer[1] < 1) and 336 or 324), x + 5, y - 5 + 2 * ((MsgTimer[1] < 3) and math.floor(MsgTimer[1]) or 4 - math.floor(MsgTimer[1])), 0, 2) else -- arrow buttons spr((math.floor(MsgTimer[1]) % 2 == 0) and 352 or 353 + math.floor(MsgTimer[1]) / 2, x, y + 2, 0, 2) -- click and pull spr(336 + math.floor(MsgTimer[1]) + ((MsgTimer[1] < 5) and 0 or -4), x + 12, y - 1, 0, 2) end local msg = {"> Click and move", "> Mouse scroll"} if Menu == 2 then msg[1], msg[2] = "> Keyboard", "> Mouse left" end if coli.touch(x - 2, y - 2, x + 29 - 9 * info, y + 14 + info) then msgAnimText({"Use to navigate:", msg[1], msg[2]}) end end -- COLI2DA local function coli_move() if pop.w == nil then pop.w = mx - pop.X pop.h = my - pop.Y end pop.X = mx - pop.w pop.Y = my - pop.h if not mp then pop.w = nil pop.h = nil end end local function coli_bSdw(iI, x, y, final, adj, color) -- buttom shadow if pop.switch[1][iI] == 0 then local _iy = 0 color = color or 14 local function cmp(i, v) return ((i == v and color ~= 7) or (i == final - v and color ~= 1)) end for i = 0, final do _iy = (cmp(i, 0)) and 0 or (cmp(i, 1)) and 1 or 2 pix(x + i, y + adj + _iy, color) end end end local function coli_bWhitep(x, y) for t = 0, 1 do for f = 0, 1 do if not (t == 0 and f == 1) then pix(x, y + 8 * t + f - math.ceil(pop.switch[1][pop.id]), 12 + f) end end end end local function coli_objs(spdX, spdY) local topBelow, leftRight = false, false -- map if CurFunc == 1 or CurFunc == 5 or CurFunc == 10 then local adj = {[1] = {192, 24}, [5] = {152, 32}, [10] = {184, -16}} local obj = {OBJ[ObjID].x - adj[CurFunc][1], OBJ[ObjID].y - adj[CurFunc][2], 8, 8} if spdY then topBelow = coli.box360(nil, spdY, obj, 0, 4) else leftRight = coli.box360(spdX, nil, obj, 0, 4) end -- void elseif (CurFunc >= 2 and CurFunc <= 4) or (CurFunc >= 7 and CurFunc <= 9) then topBelow = true leftRight = true end if spdY and topBelow then OBJ[ObjID].y = OBJ[ObjID].y + spdY elseif spdX and leftRight then OBJ[ObjID].x = OBJ[ObjID].x + spdX end end local function coli_whrm(typ, add) local w, h, r = (typ == 'w'), (typ == 'h'), (typ == 'r') local jumpNow = true local notJump = {2, 3, 4, 7, 8, 9, 11} for i = 1, #notJump do if CurFunc == notJump[i] then jumpNow = false break end end if jumpNow then return end local newValue = ((w) and OBJ[ObjID].width or (h) and OBJ[ObjID].height or (r) and OBJ[ObjID].radius or FuncMode) + add if w then OBJ[ ObjID].width = newValue return end if h then OBJ[ObjID].height = newValue return end if r then OBJ[ObjID].radius = newValue return end FuncMode = newValue ModeSwapped = true end local function coli_swap(cursor) if cursor then OBJ[ObjID].cursorPoint = pop:onOff(OBJ[ObjID].cursorPoint) return end if ObjID == 1 then return 2 end return 1 end local function coli_btnInfo(x, y, w, h, t) if coli.touch(pop.x + x, pop.y + y, pop.x + x + w - 1, pop.y + y + h - 1) then local _w = plus.length(t, false, 1, true) + 3 local _x, _y = mx + 5, my - 4 if _x + _w >= 238 then _x = mx - 5 - _w end if _y < 6 then _y = _y + 6 elseif _y > 126 then _y = _y - 6 end rect( _x, _y, _w, 9, 0) rectb(_x, _y, _w, 9, 14) print(t, _x + 2, _y + 2, 13, false, 1, true) end end local function coli2DA_sc(id) local color = 12 -- general local objid = (ObjID == 1) and 2 or 1 local o1, o2 = OBJ[ObjID], OBJ[objid] local w, h, r = o1.width, o1.height, o1.radius local _w, _h, _r = o2.width, o2.height, o2.radius for i = 1, 2 do if OBJ[i].automove then if OBJ[i].spdX == nil then local sign = {-1, 1} OBJ[i].spdX = math.random(2) * sign[math.random(2)] / math.random(2, 3) OBJ[i].spdY = math.random(2) * sign[math.random(2)] / math.random(2, 3) end local x1, y1, x2, y2 = OBJ[i].x, OBJ[i].y, OBJ[i].x, OBJ[i].y if CurFunc ~= 3 then if CurFunc == 2 or (CurFunc == 4 and FuncMode == 1) or (CurFunc == 8 and i == 1) then local rad = (OBJ[i].cursorPoint) and 0 or OBJ[i].radius x1, y1, x2, y2 = x1 - rad, y1 - rad, x2 + rad, y2 + rad else x2 = x2 + OBJ[i].width - 1 y2 = y2 + OBJ[i].height - 1 end end if y1 <= 1 or y2 >= 134 then OBJ[i].spdY = -OBJ[i].spdY end if x1 <= 121 or x2 >= 238 then OBJ[i].spdX = -OBJ[i].spdX end OBJ[i].y = OBJ[i].y + OBJ[i].spdY OBJ[i].x = OBJ[i].x + OBJ[i].spdX elseif OBJ[i].spdX ~= nil then OBJ[i].spdX, OBJ[i].spdY = nil, nil end end -- multi-objects if id == 2 then -- circle if o1.cursorPoint then r = 0 end if o2.cursorPoint then _r = 0 end o1.x, o1.y = insArea(r, r, -r, -r) if coli.circle({o1.x, o1.y, r}, {o2.x, o2.y, _r}) then color = 4 end circb(o1.x, o1.y, r, color) circb(o2.x, o2.y, _r, color) return end if id == 3 then -- distance o1.x, o1.y = insArea(0, 0, 0, 0) line(o1.x, o1.y, o2.x, o2.y, 1) pix(o1.x, o1.y, 12) pix(o2.x, o2.y, 12) local dist = coli.distance({o1.x, o1.y}, {o2.x, o2.y}) if FuncMode == 1 then dist = math.floor(dist) end plus.pBorder(tostring(dist), 180, 130, 12, 0, false, 1, nil, false, true) return end if id == 7 or id == 11 then -- rectangle, touch local isc = (id == 11) -- it is cursor if (not isc and o1.cursorPoint) or (isc and not o1.cursorPoint) then w, h = 1, 1 end if o2.cursorPoint then _w, _h = 1, 1 end o1.x, o1.y = insArea(0, 0, w, h, true) if coli.rectangle({o1.x, o1.y, w, h}, {o2.x, o2.y, _w, _h}) then color = 4 end rectb(o1.x, o1.y, w, h, color) rectb(o2.x, o2.y, _w, _h, color) if isc then spr(242, o1.x - 1, o1.y - 1, 6) -- default cursor if coli.touch(121, 1, 238, 134) then pix(mx, my, color) end end return end if id == 4 then -- impactPixel local m0 = (FuncMode == 0) local x, y = coli.impactPixel(((m0) and "rect" or "circ"), o1, o2) if m0 then o1.x, o1.y = insArea(0, 0, w, h, true) o2.x, o2.y = insArea(0, 0, _w, _h, true, true) rectb(o1.x, o1.y, w, h, color) rectb(o2.x, o2.y, _w, _h, color) else o1.x, o1.y = insArea( r, r, -r, -r) o2.x, o2.y = insArea(_r, _r, -_r, -_r, false, true) circb(o1.x, o1.y, r, color) circb(o2.x, o2.y, _r, color) end if x then circ(x, y, 1, 4) end return end if id == 8 then -- shapesMix if ObjID == 1 then if coli.shapesMix({o1.x, o1.y, r}, {o2.x, o2.y, _w, _h}) then color = 4 end else if coli.shapesMix({o2.x, o2.y, _r}, {o1.x, o1.y, w, h}) then color = 4 end end if ObjID == 1 then o1.x, o1.y = insArea(r, r, -r, -r) circb(o1.x, o1.y, r, color) rectb(o2.x, o2.y, _w, _h, color) else o1.x, o1.y = insArea(0, 0, w, h, true) rectb(o1.x, o1.y, w, h, color) circb(o2.x, o2.y, _r, color) end return end -- single object local mapInfo = { [1] = {0, 3, 5, 5, 160, 48}, -- box360 [5] = {4, 1, 7, 7, 152, 40}, -- mapAlign [9] = {0, 0, 3, 3, 168, 56}, -- tile [10] = {0, 7, 7, 7, 152, 40}, -- tileCross } if mapInfo[id] ~= nil then map(table.unpack(mapInfo[id])) rect( o1.x, o1.y, 8, 8, 6) rectb(o1.x, o1.y, 8, 8, 12) if id == 5 then local a, b = math.floor(o1.x), math.floor(o1.y) local x, y = coli.mapAlign({a, b}) plus.pCenter("| X: "..( a - 160).." | Y: "..( b - 48).." |", 180, 20, 12) plus.pCenter("| AX: "..(x - 160).." | AY: "..(y - 48).." |", 180, 30, 12) end return end if id == 6 then -- newBody pix(180, 25, 12) plus.pCenter("simp: x, y", 180, 35, 12, false, 1, true) circ(180, 63, 4, 12) plus.pCenter("circ: x, y, radius", 180, 73, 12, false, 1, true) rect(177, 97, 7, 7, 12) plus.pCenter("rect: x, y, width, height", 180, 110, 12, false, 1, true) return end end local function coli2DA_pu(clickOn) local opt = { mv = {1, 2, 3, 4, 5, 7, 8, 10}, -- move wh = {4, 7, 8, 11}, -- width and height rd = {2, 4, 8}, -- radius cs = {2, 7, 11}, -- cursor swap ob = {2, 3, 4, 7, 8}, -- object swap am = {2, 3, 4, 7, 8, 11}, -- automove md = {3, 4, 9}, -- mode } if clickOn ~= nil then local mMx = (CurFunc == 3 or CurFunc == 4) and 1 or (CurFunc == 9) and 3 or 0 -- mode max if pop:gStt(1) and OBJ[ObjID].y > 1 then coli_objs(nil, -0.25) elseif pop:gStt(2) and OBJ[ObjID].y < 127 then coli_objs(nil, 0.25) elseif pop:gStt(3) and OBJ[ObjID].x > 121 then coli_objs(-0.25, nil) elseif pop:gStt(4) and OBJ[ObjID].x < 231 then coli_objs( 0.25, nil) elseif pop:gStt(5) and OBJ[ObjID].width > 5 then coli_whrm('w', -5) elseif pop:gStt(6) and OBJ[ObjID].width < 50 then coli_whrm('w', 5) elseif pop:gStt(7) and OBJ[ObjID].height > 5 then coli_whrm('h', -5) elseif pop:gStt(8) and OBJ[ObjID].height < 50 then coli_whrm('h', 5) elseif pop:gStt(9) and OBJ[ObjID].radius > 5 then coli_whrm('r', -5) elseif pop:gStt(10) and OBJ[ObjID].radius < 50 then coli_whrm('r', 5) elseif pop:gStt(11) then coli_move() elseif pop:gStt(12) then coli_swap(true) elseif pop:gStt(13) then ObjID = coli_swap() elseif pop:gStt(14) then local id = ((CurFunc == 11) and 2 or ObjID) OBJ[id].automove = pop:onOff(OBJ[id].automove) elseif pop:gStt(15) and FuncMode > 0 then coli_whrm('m', -1) elseif pop:gStt(16) and FuncMode < mMx then coli_whrm('m', 1) end -- buttom timer for i = 1, #pop.switch[1] do if i > 4 and i ~= 11 then if pop.switch[1][i] > 0 then pop.switch[1][i] = pop.switch[1][i] - 0.05 if pop.switch[1][i] < 0 then pop.switch[1][i] = 0 end end else if not mp and pop.switch[1][i] == 1 then pop.switch[1][i] = 0 end end end -- tile if CurFunc == 9 and ModeSwapped then ModeSwapped = false local pos = {{1, 0}, {1, 2}, {0, 1}, {2, 1}} -- top, bottom, left, right for i = 1, 4 do mset(pos[i][1], pos[i][2], 255) end -- clear mset(pos[FuncMode + 1][1], pos[FuncMode + 1][2], 239) -- set tile end -- 60tics/p if not clickOn and pop.id ~= 11 then return end -- 1tic/click pop.id = 0 local function ckCoord(typ, x, y, w, h) x, y = x + pop.x, y + pop.y if not coli.touch(x, y, x + w, y + h) then return end local cond = false cond = (typ == "EV") local Nwhr = (typ ~= 'wh' and typ ~= 'rd') -- NO width, height or radius if not cond then -- every for i = 1, #opt[typ] do if CurFunc == opt[typ][i] then if (CurFunc ~= 4 and CurFunc ~= 8) or (CurFunc == 4 and (Nwhr or (typ == "rd" and FuncMode == 1) or (typ == "wh" and FuncMode == 0))) or (CurFunc == 8 and (Nwhr or (typ == "rd" and ObjID == 1) or (typ == "wh" and ObjID == 2))) then cond = true break end end end end if cond and pop.switch[1][pop.id] == 0 then pop.switch[1][pop.id] = 1 end end -- update position, [for], ~ index, check collision --[[ move ]] pop:xy(1, 7) for i = 0, 3 do pop:gID() ckCoord("mv", 0, 8 * i, 6, 5) end --[[ dime ]] pop:xy(9, 1) for i = 0, 2 do for j = 0, 1 do pop:gID() ckCoord(((i < 2) and "wh" or "rd"), 11 * j, 11 * i, 9, 8) end end --[[ popm ]] pop:xy(31, 6) pop:gID() ckCoord("EV", 0, 0, 9, 6) --[[ form ]] pop:xy(31, 15) for i = 0, 1 do pop:gID() ckCoord(((i == 0) and "cs" or "ob"), 0, 12 * i, 9, 9) end --[[ auto ]] pop:xy(9, 35) pop:gID() ckCoord("am", 0, 0, 6, 7) --[[ mode ]] pop:xy(17, 34) for i = 0, 1 do pop:gID() ckCoord("md", 7 * i, 0, 5, 8) end return end pop.id = 0 local _y = nil -- joker rect( pop.X, pop.Y, 42, 45, 0) -- background rectb(pop.X - 1, pop.Y - 1, 44, 47, 12) -- border 01 rectb(pop.X - 2, pop.Y - 2, 46, 49, ((ObjID == 1) and 7 or 1)) -- object color (green = 1; red = 2) rectb(pop.X - 3, pop.Y - 3, 48, 51, 13) -- border 02 -- to show width e height/radius value local v = nil -- one use local whr = {OBJ[ObjID].width, OBJ[ObjID].height, OBJ[ObjID].radius} local onWiHe, onRadi, onMode = false, false, false local usingWH = {4, 7, 8, 11} local usingR = {2, 4, 8} local usingM = {3, 4, 5, 9} for i = 1, #usingWH do if CurFunc == usingWH[i] then onWiHe = true break end end for i = 1, #usingR do if CurFunc == usingR[ i] then onRadi = true break end end for i = 1, #usingM do if CurFunc == usingM[ i] then onMode = true break end end -- move to: top, bottom, left, right pop:xy(1, 7) for i = 0, 3 do _y = pop.y + 8 * i + pop:gID() spr(((i < 2) and 275 or 291), pop.x - ((i == 3) and 1 or 0), _y - ((i == 1) and 2 or 0), 8, 1, ((i == 1) and 2 or (i == 3) and 1 or 0)) coli_bSdw(pop.id, pop.x, _y - 1, 6, 5) end -- change dimensions: width, height, radius pop:xy(8, 1) for i = 0, 2 do for f = 0, 1 do _y = pop.y + 11 * i + pop:gID() if f == 0 then spr(256, pop.x + 1, _y, 8) spr(257, pop.x + 7, _y, 8) end if f == 0 then print(string.sub("WHR", i + 1, i + 1).." :", pop.x + 3, 2 + _y, 13, false, 1, true) end line(pop.x + 3 + 9 * f, 8 + _y, pop.x + 10 + 9 * f, 8 + _y, ((f == 0) and 2 or 6)) coli_bWhitep(pop.x + 11, _y) if f == 1 then for t = 0, 1 do spr(258, pop.x + 12 + 4 * t, _y, 8) end end coli_bSdw(pop.id, pop.x + 1 + 11 * f, _y, 9, 7, 1 + 6 * f) end v = whr[i + 1] print((((onWiHe and onRadi) or (onWiHe and i < 2) or (onRadi and i == 2)) and ((v < 10) and "0"..v or v) or "--"), pop.x + 13, 2 + _y, 13, false, 1, true) end -- move popup to any direction (press/click and move) pop:xy(31, 6) for i = 0, 1 do if i == 1 then pop.id = pop.id - 1 end spr(259, pop.x + 2 * i, pop.y + pop:gID(), 8, 1, i) end coli_bSdw(pop.id, pop.x, pop.y + 4, 9, 1) -- change format: cursor <-> object, object type pop:xy(31, 15) for i = 0, 1 do _y = pop.y + 12 * i + pop:gID() spr(272 + i, pop.x, _y, 8) spr(274, pop.x + 8, _y, 8) spr(289, pop.x, _y + 8, 8) pix(pop.x + 8, _y + 8, 13) coli_bSdw(pop.id, pop.x, _y, 9, 8) end -- automove pop:xy(9, 35) spr(288, pop.x, pop.y + pop:gID(), 8) coli_bSdw(pop.id, pop.x, pop.y, 6, 6) -- change mode pop:xy(17, 34) for i = 0, 1 do _y = pop.y + pop:gID() if i == 0 then spr(256, pop.x, _y, 8) else spr(258, pop.x + 7, _y, 8) end line(pop.x + 2 + 5 * i, _y + 8, pop.x + 5 + 5 * i, _y + 8, ((i == 0) and 2 or 6)) coli_bWhitep(pop.x + 6, _y) if i == 0 then print("M:", pop.x + 2, _y + 2, 13, false, 1, true) end coli_bSdw(pop.id, pop.x + 7 * i, pop.y, 5, 7, 1 + 6 * i) end print(((onMode) and FuncMode or "-"), pop.x + 8, _y + 2, 13, false, 1, true) pop:xy(0, 0) local toMsg = { {1, 7, 7, 30, "move to"}, {9, 1, 21, 31, "dimensions"}, {31, 6, 10, 7, "move popup"}, {31, 15, 10, 10, "cursor point: "..tostring(OBJ[ObjID].cursorPoint)}, {31, 27, 10, 10, "current object: "..ObjID}, {9, 35, 7, 8, "automove: "..tostring(OBJ[ObjID].automove)}, {17, 34, 13, 9, "mode"} } for i = 1, #toMsg do coli_btnInfo(table.unpack(toMsg[i])) end end -- PRINT+ local function print_plus_sc(id) local _txt, _x, _y, _w, _h = "", 0, 0, 0, 0 local txt = "Hello World!" local x, y = plus.center(txt, 180, 68) local w, h = plus.length(txt) local _x = x + w // 2 - 1 local _y = y + h // - 1 local function cutTxt(i) txt = string.sub(txt, 1, ((i < 2) and 12 or 5)) return txt end local function scale(i) return ((i == 2) and i or 1) end -- center if id == 1 then local xy = {txt, "", ""} for i = 0, 1 do x, y = plus.center(txt, 160 + 40 * i, 46 + 51 * i, false, 1, (i == 0)) xy[2] = "X: "..(160 + 40 * i).." -> "..x xy[3] = "Y: 0"..(46 + 51 * i).." -> 0"..y for j = 0, 2 do plus.pCenter(xy[j + 1], 160 + 40 * i, 46 + 7 * j + 31 * i, ((j == 0) and 12 or 13), false, 1, (i == 0 or j > 0)) end end return end -- length if id == 2 then local _scl, _y = 0, 0 for i = 0, 2 do -- values _scl = scale(i) _y = ((_scl == 2) and 2 or 1) -- "Hello World!" cutTxt(i) x, y = plus.center(txt, 175, 38 + 25 * i, false, _scl, (i == 0)) w, h = plus.length(txt, false, _scl, (i == 0)) print(txt, x, y, 4, false, _scl, (i == 0)) line(x, y + 6 * _scl, x + w, y + 6 * _scl, 6) -- width line(x + w + 3, y, x + w + 3, y + h - 1, 2) -- height -- dimensions x, y = plus.center("00px", 175, 38 + 25 * i, false, 1, true) print(w.."px", x, y + 8 * ((_scl == 2) and 1.5 or 1), 6, false, 1, true) -- width print(h.."px", x + w // 2 + 13, y - i // 2, 2, false, 1, true) -- height end return end -- pBorder if id == 3 then for i = 1, 2 do for j = 0, 2 do plus.pBorder(cutTxt(j), 180, 30 + ((j < 2) and 10 * j or 23) + 45 * (i - 1) + ((i == 1) and 0 or 2 * j), 4, 2, false, scale(j), i, (j == 0), true) end end return end -- pCenter if id == 4 then for i = 0, 2 do y = 33 + 35 * i line(121, y, 238, y, 15) -- width line(180, 1, 180, 134, 15) -- height plus.pCenter(cutTxt(i), 180, y, 12, false, scale(i), (i == 0)) end return end -- pList if id == 5 then local effec = {nil, {"border", 2}, {"shadow", {"2-1", "2-3"}}} local parag = {"Hello", "World", "!"} for x = 160, 200, 40 do for y = 35, 105, 35 do plus.pList(parag, x, y, 4, 7, false, 1, (x == 200), ((y == 35) and -1 or (y == 70) and 0 or 1), true, effec[y // 30]) end end return end -- pShadow if id == 6 then local shw = {2, {"2-1", "2-3"}, {"2-2-1", "2-1-1"}} for i = 0, 2 do plus.pShadow(cutTxt(i), shw[i + 1], 180, 34 + ((i < 2 ) and 30 * i or 64), 4, false, scale(i), (i == 0), true) end return end -- title if id == 7 then line(121, 68, 238, 68, 15) line(180, 1, 180, 134, 15) for i = 0, 1 do plus.title({181, 182, 197, 197, 198, 213, 214, 198, 229, 197, 230}, 180, 68, 0, 1, nil, 5, 5, nil, nil, true, true, (i == 1)) end return end end -- MAGIC_PALETTE local function Magic_Palette_sc(id) if id < 3 or id > 4 then print("Visual representation", 122, 129, 15, false, 1, true) end -- save if id == 1 then local txt = {"Decimal:", "{{r, g, b}, { ... }, {r, g, b}}", "Hexadecimal:", "\"rrggbb...rrggbb\""} local y = {45, 55, 75, 85} local color = {12, 13, 12, 13} for i = 1, 4 do plus.pCenter(txt[i], 180, y[i], 13 - i % 2, false, 1, (i > 1)) end plus.pCenter("[ 0 - ( ... ) - 15 ]", 180, 100, 14, false, 1, true) return end -- sort if id == 2 then plus.pCenter("Return:", 180, 43, 12) plus.pList({"r, g, b", "{r, g, b}", "{red = r, green = g, blue = b}", "\"r, g, b\" or \"#rrggbb\""}, 180, 70, 13, 12, false, 1, true, 0, true) return end -- shine; swap if id == 3 then local txt = "" for i = 25, 115, 90 do rect(121, i - 3, 118, 7, 15) txt = ((i == 25) and "Reset palette" or "<< "..((PalShine) and "[]" or "[>").." >>") plus.pCenter(txt, 180, i, 12) end rect(121, 122, 118, 7, 15) txt = ((PalToDefault) and "Back to default" or "Limited (0-255)") plus.pCenter(txt, 180, 125, ((PalShine) and 14 or 12), false, 1, true) for i = 160, 200, 40 do line(i, 112, i, 119, 0) end spr(183, 148, 44, nil, 2, 0, 0, 4, 3) return end if id == 4 then local palNames = {"Sweetie-16", "PICO-8", "Pixel Vision 8"} rect(121, 22, 118, 7, 15) plus.pCenter(palNames[PalId], 180, 25, ((PalId == 2) and 2 or 12)) spr(183, 148, 36, nil, 2, 0, 0, 4, 4) return end -- toDec if id == 5 then plus.pList({"\"ffffff\"", "||", "\\/", "{255, 255, 255}"}, 180, 61, 12, 15, false, 1, false, 0, true) return end -- toHex if id == 6 then plus.pList({"{255, 255, 255}", "||", "\\/", "\"ffffff\""}, 180, 61, 12, 15, false, 1, false, 0, true) return end end local function Magic_Palette_pu(clickOn) if CurFunc < 3 or CurFunc > 4 then return end if clickOn ~= nil then local pals = { "1A1C2C5D275DB13E53EF7D57FFCD75A7F07038B76425717929366F3B5DC941A6F673EFF7F4F4F494B0C2566C86333C57", -- tic80 "0000001D2B537E2553008751AB52365F574FC2C3C7FFF1E8FF004DFFA300FFEC2700E43629ADFF83769CFF77A8FFCCAA", -- pico8 "2D1B2E218A913CC2FA9AF6FD4A247C574B67937AC58AE25D8E2B45F04156F272CED3C0A8C5754AF2A759F7DB53F9F4EA", -- pv8 } -- shine if CurFunc == 3 and PalShine then local qtt = 0 for i = 1, 11 do if PalShineSpd[i] ~= 0 then if mpal.shine(PalShineSpd[i], i, ((PalToDefault) and PalSaved or nil)) ~= 0 then PalShineSpd[i] = 0 end else qtt = qtt + 1 end end PalShine = (qtt ~= 11) end if not clickOn then return end if CurFunc == 3 then if coli.touch(121, 22, 238, 29) then clearPalette() -- 'reset palette' elseif coli.touch(121, 112, 238, 119) then local spd = (mx < 160) and -1 or (mx > 200) and 1 or 0 -- to left; to right; pause/play PalShine = (spd ~= 0) for i = 1, 11 do PalShineSpd[i] = spd end elseif coli.touch(121, 122, 238, 129) and not PalShine then PalToDefault = pop:onOff(PalToDefault) end return end -- swap local up = false if coli.touch(121, 22, 179, 29) and PalId > 1 then PalId, up = PalId - 1, true elseif coli.touch(180, 22, 238, 29) and PalId < 3 then PalId, up = PalId + 1, true end if up then mpal.swap(pals[PalId], "palette") poke(0x03ff8, (PalId == 1) and 15 or 5) end return end -- swap ("fix" text color) if PalId == 2 then plus.pCenter("TinyLibrary", 60, 3, 2) plus.pCenter("< Magic_Palette >", 60, 131, 2) end end -- LONGBIT local function longBit_sc(id) if id == 9 or id == 11 then print("Visual representation", 122, 129, 15, false, 1, true) end -- boot if id <= 3 then local num = {"6819", "----0", "-719"} if id == 1 then memBtn("BOOT", 26) elseif id == 2 then memBtn("CLEAR", 33) end plus.pCenter("Current state:", 180, 30, 12) local mem = "" for i = 1, 9 do mem = ((id ~= 2) and ("#"..i.." - ") or toClass(i).." - ") plus.pCenter(mem..lbit.getAll(toClass(i), id == 3), 180, 40 + 8 * (i - 1), 13, false, 1, true) end return end -- getBool, getNum if id == 4 or id == 6 then memTitle() local class = toClass(MemID) local value = tostring((id == 6) and lbit.getNum(SubMemID, class) or lbit.getBool(SubMemID, class)) rect(121, 62, 118, 7, 15) -- change "value stored" local adx = (5 * (SubMemID - 1)) + SubMemID line(153 + adx, 70, 157 + adx, 70, 6) plus.pCenter(lbit.getAll(class, true), 180, 65, 13, true) plus.pCenter(value, 180, 90, 13) if id == 4 then plus.pCenter("'#"..SubMemID.."' == 1 ?", 180, 100, 15) end return end -- getClass if id == 5 then plus.pCenter("Current classes:", 180, 30, 12) for i = 1, 9 do plus.pCenter("#"..i.." - "..toClass(i), 180, 40 + 8 * (i - 1), 13, false, 1, true) end return end -- update if id == 7 then memTitle() memBtn("UPDATE", 38) local class = toClass(MemID) plus.pCenter(lbit.getAll(class, true), 180, 65, 13) local txt = {"'#2' ~= 5", "'#6' ~= 05", "'#9' ~= 1"} for i = 0, 2 do plus.pCenter(txt[i + 1].." ?", 180, 80 + 7 * i, 13, false, 1, true) end return end -- setClass if id == 9 then local n = "----" local txt = {{n, "conf"}, {n, "skin"}, {n, "ctrl"}} for i = 1, 3 do memPop(130, 20 + 20 * i, i - 1, txt[i]) end return end -- setAll, setNum if id == 8 or id == 10 then memTitle() local class = toClass(MemID) local Y = (CurFunc == 10) and 70 or 57 local mem = {tostring(((CurFunc == 10) and lbit.getNum(SubMemID, class, SubMemLen) or lbit.getAll(class))), lbit.getAll(class, true)} local ttl = {"Value stored:", "Full value:"} rect(121, Y + 5, 118, 7, 15) -- change "value stored" for i = 1, 2 do plus.pCenter(ttl[i], 180, Y + 18 * (i - 1), 12) plus.pCenter(mem[i], 180, Y + 8 + 18 * (i - 1), 13, false, 1, true) end if CurFunc == 10 then local txt = "< Sub-memory " local ttl = {txt.."#"..SubMemID..">", txt.."length #"..SubMemLen.." >"} for i = 0, 1 do rect(121, 42 + 10 * i, 118, 8, 15) plus.pCenter(ttl[i + 1], 180, 45 + 10 * i, ((SubMemID + SubMemLen == 10 and i == 1) and 14 or 12), false, 1, true) end -- sub-memory(ies) selected local x1 = 163 + 4 * (SubMemID - 1) local y1 = Y + 30 local x2 = x1 + 4 * SubMemLen - 1 line(x1, y1, x2, y1, 6) end return end -- swapClass if id == 11 then local txt = {{"chest", "inventory"}, {"enemy", "ally"}, {"man", "werewolf"}} for i = 1, 3 do memPop(130, 20 + 20 * i, i - 1, txt[i]) end return end end local function longBit_pu(clickOn) if not clickOn then return end local opts, valid = {1, 2, 4, 6, 7, 8, 10}, false for i = 1, #opts do if CurFunc == opts[i] then valid = true break end end if not valid then return end local id = CurFunc -- (memTitle) set pmem index if id == 4 or (id >= 6 and id <= 8) or id == 10 then if coli.touch(121, 24, 179, 35) and MemID > 1 then MemID = MemID - 1 elseif coli.touch(180, 24, 238, 35) and MemID < 9 then MemID = MemID + 1 end end -- getBool, getNum if id == 4 or id == 6 then if coli.touch(121, 62, 179, 69) and SubMemID > 1 then SubMemID = SubMemID - 1 end if coli.touch(180, 62, 238, 69) and SubMemID < 9 then SubMemID = SubMemID + 1 end return end -- boot if id == 1 and coli.touch(122, 125, 147, 133) then local mem = {} for i = 1, 9 do mem[i] = "" for j = 1, 9 do mem[i] = mem[i]..i end end lbit.boot(mem, true, 1) return end -- clear if id == 2 and coli.touch(122, 125, 154, 133) then lbit.clear("memory", false, 1) return end -- update if id == 7 and coli.touch(122, 125, 159, 133) then lbit.update(toClass(MemID), {"5", "06", "1"}, {2, 6, 9}) return end -- setAll, setNum local class = toClass(MemID) local all = lbit.getAll(class) local sub = lbit.getNum(SubMemID, class, SubMemLen) local curVal = ((id == 10) and sub or all) -- update values stored local Y = (id == 10) and 75 or 62 if coli.touch(121, Y, 179, Y + 6) and curVal - 1 > 0 then if id == 8 then lbit.setAll(-1, class, true) elseif id == 10 then lbit.setNum(sub - 1, SubMemID, class, SubMemLen) end elseif coli.touch(180, Y, 238, Y + 6) and all + 1 < 999999999 then if id == 8 then lbit.setAll(1, class, true) elseif id == 10 and sub + 1 < 10 ^ SubMemLen then lbit.setNum(sub + 1, SubMemID, class, SubMemLen) end end -- setNum if id ~= 10 then return end for y = 42, 52, 10 do -- set submemory id and length if coli.touch(121, y, 179, y + 7) then if y == 42 and SubMemID > 1 then SubMemID = SubMemID - 1 elseif y == 52 and SubMemLen > 1 then SubMemLen = SubMemLen - 1 end elseif coli.touch(180, y, 238, y + 7) then local som = SubMemID + SubMemLen - 1 if y == 42 and SubMemID < 9 then SubMemID = SubMemID + 1 if som >= 9 then SubMemLen = SubMemLen - 1 end elseif y == 52 and som < 9 then SubMemLen = SubMemLen + 1 end end end end -- summary local function showcase() local libs = {coli2DA_sc, print_plus_sc, Magic_Palette_sc, longBit_sc} libs[CurLib](CurFunc) end local function panelpopup(onClick) local libs = {coli2DA_pu, function() end, Magic_Palette_pu, longBit_pu} libs[CurLib](onClick) end -- swap menu local function setMenuValues(ID) local id = math.floor(ID) Menu = (ID - id == 0) and id or Menu clearPalette() UpBorderColor = true if id ~= 0 and ID == id then HelpMsg = 300 end if id ~= 2 then BorderColor = 0 end if id == 1 then InfoY = 0 InfoDif = nil return end if id == 2 then CurFunc = 1 UsingCursor = false for i = 1, 16 do pop.switch[1][i] = 0 end defaultValues(true) if ID > id then return end CurLib = 1 BorderColor = 15 return end if id == 3 then return end ShineX = 242 ShineMax = math.random(250, 400) CopyTimer = 0 end -- main functions local function UPDATE() mx, my, mp, _, mq, _, ms = mouse() -- click "filter" local clickOn = false if not mp then Tap = false elseif mp and not Tap then Tap = true clickOn = true end -- @U0 if Menu == 0 then local pos = {{26, 100, 72, 118}, {96, 90, 142, 108}, {166, 100, 212, 118}} for i = 1, 3 do if clickOn and coli.touch(pos[i][1], pos[i][2], pos[i][3], pos[i][4]) then setMenuValues(i) end end if clickOn and coli.touch(230, 0, 239, 9) then pmem(0, (pmem(0) == 0) and 1 or 0) end return else -- back to main menu (0) if (mq and not mp) or (clickOn and not coli.touch(0, 0, 239, 135)) then setMenuValues(0) end end -- @U1 if Menu == 1 then if ms < 0 and InfoY > -127 then InfoY = InfoY - 8.375 elseif ms > 0 and InfoY < 0 then InfoY = InfoY + 8.375 end if mp then if InfoDif == nil then InfoDif = math.abs(my - InfoY) end InfoY = my - InfoDif else InfoDif = nil end if InfoY < -127 then InfoY = -127 elseif InfoY > 0 then InfoY = 0 end return end -- @U2 if Menu == 2 then AbovePopup = (CurLib == 1 and coli.touch(pop.X - 3, pop.Y - 3, pop.X + 44, pop.Y + 47)) panelpopup(clickOn) local ctrl local function arrow(i, x1, y1, x2, y2) return i == 0 and not AbovePopup and clickOn and coli.touch(x1, y1, x2, y2) end for i = 0, 58, 58 do ctrl = (i == 0) and btnp or keyp if ctrl(i, 30, 6) and CurFunc > 1 then CurFunc = CurFunc - 1 defaultValues() break elseif ctrl(i + 1, 30, 6) and CurFunc < #SHOW[CurLib] then CurFunc = CurFunc + 1 defaultValues() break elseif (ctrl(i + 2, 30, 6) or arrow(i, 1, 129, 59, 134)) and CurLib > 1 then CurLib = CurLib - 1 setMenuValues(2.1) break elseif (ctrl(i + 3, 30, 6) or arrow(i, 60, 129, 119, 134)) and CurLib < #SHOW then CurLib = CurLib + 1 setMenuValues(2.1) break end end if AbovePopup or msgAnim(true, 0) then return end for i = 0, #SHOW[CurLib] - 1 do if clickOn and coli.touch(1, 8 + 7 * i, 119, 14 + 7 * i) then CurFunc = i + 1 defaultValues() break end end return end -- @U3 if Menu == 3 then local y = 0 for i = 1, 3 do y = 38 + 21 * (i - 1) if clickOn and coli.touch(226, y, 237, y + 15) then CopyTimer = 119 trace("\n\nTinyLibrary - "..string.gsub(LINK[i][1], "[> ]", '').."\n"..string.gsub(LINK[i][2], "[> ]", '').."\n", LINK[i][3]) break end end return end end local function DRAW() cls() if Menu ~= 0 then poke(0x03ff8, ((coli.touch(0, 0, 239, 135)) and BorderColor or 12)) elseif UpBorderColor then UpBorderColor = false poke(0x03ff8, BorderColor) end -- @D0 if Menu == 0 then -- title spr(0, 56, 8, 0, 1, 0, 0, 16, 9) if ShineX < 242 then ShineX = ShineX + 2 else if ShineX == 242 then ShineMax = math.random(300, 400) end ShineX = ShineX + 0.1 if ShineX >= ShineMax then ShineX = 74 end end local _x, _y, ccur, color = 0, 0, 0, {[3] = 13, [4] = 12, [1] = 2} for y = 70, 0, -1 do for x = 10, 0, -1 do _x, _y = ShineX + x - y, 9 + y ccur = color[pix(_x, _y)] if ccur ~= nil then pix(_x, _y, ccur) end end end -- hide cursor local above = 0 if coli.touch(230, 0, 239, 9) then above = 2 end if above > 0 then rectb(230, 0, 10, 12, 12) end spr(240 + above + pmem(0), 232, 2, 6) -- options local toOpt = { {{180, 194, 196, 178}, 28, 102}, -- info {{176, 177, 178, 179}, 98, 92 }, -- show {{192, 193, 194, 195}, 168, 102}, -- link } local bcolor for i = 1, 3 do bcolor = 14 if coli.touch(toOpt[i][2] - 2, toOpt[i][3] - 2, toOpt[i][2] + 44, toOpt[i][3] + 16) then bcolor = 13 for j = 1, 4 do toOpt[i][1][j] = toOpt[i][1][j] + 32 end end rectb(toOpt[i][2] - 2, toOpt[i][3] - 2, 47, 19, bcolor) plus.title(toOpt[i][1], toOpt[i][2], toOpt[i][3], 0, 1, 2, 5) end -- credits print("(C) DuckAfire", 2, 129, 15, false, 1, true) print("ShowCase v2.10.2", 181, 129, 15, false, 1, true) return end -- @D1 if Menu == 1 then print(INFO, 0, InfoY, 13, false, 1, true) msgAnim(false, 1) return end -- @D2 if Menu == 2 then local letter, oText, nText = '', "", "" local itemID, itemColor, funcColor = nil, 2, nil local above = AbovePopup or msgAnim(true, 0) for i = 0, #SHOW[CurLib] - 1 do funcColor = nil if coli.touch(1, 8 + 7 * i, 119, 14 + 7 * i) and not above then itemID = i + 1 funcColor = 2 end if CurFunc - 1 == i then funcColor = (funcColor == nil) and 6 or 4 itemColor = (funcColor == 6 ) and 2 or 4 end if funcColor ~= nil then rect(1, 8 + 7 * i, 119, 7, funcColor) end oText = SHOW[CurLib][i + 1] nText = "" for j = 1, #oText do letter = string.sub(oText, j, j) if letter == '(' then break end nText = nText..letter end print(nText, 2, 9 + 7 * i, (funcColor == nil) and 13 or 0, false, 1, true) end -- background rectb(0, 0, 240, 136, 14) -- line border line( 120, 0, 120, 135, 14) rect( 121, 1, 118, 134, 0) showcase() if itemID ~= nil then -- print all function parameters local text = SHOW[CurLib][itemID] local length = plus.length(text, false, 1, true) // 235 local width = plus.length(text, false, 1, true) - 118 local xw = 120 + width local y = 8 + 7 * (itemID - 1) local _y = y + 7 * (length + 1) if width > 0 then line(120, y - 1, xw, y - 1, 0) -- top line(120, _y, xw, _y, 0) -- bottom line(xw, y - 1, xw, _y, 0) -- right for i = 0, length do rect(1, y + 7 * i, 119 + width, 7, itemColor) end end local bkText = text for i = 1, length + 1 do text = string.sub(bkText, 1 + 65 * (i - 1), 65 * i) print(text, 2, y + 1 + 7 * (i - 1), 0, false, 1, true) end end -- bars rect( 1, 1, 119, 7, 14) -- cartridge name (top) rect( 1, 128, 119, 7, 14) -- library name (bottom) local libraries = {"coli2DA", "print+", "Magic_Palette", "longBit"} plus.pCenter("TinyLibrary", 60, 3, 12) plus.pCenter("< "..libraries[CurLib].." >", 60, 131, 12) panelpopup(nil) msgAnim(false, 0) return end -- @D3 if Menu == 3 then for i = 0, 3 do print("============================================================", 0, 33 + 21 * i, 13) end local y, above = 0, 0 for i = 1, #LINK do for j = 1, 2 do  print(LINK[i][j], 0, 40 + 7 * (j - 1) + 21 * (i - 1), 13, false, 1, (j == 2)) y, above = 38 + 21 * (i - 1), 0 if coli.touch(226, y, 237, y + 15) then above = 1 end if above > 0 then rectb(226, y, 12, 16, 12) end spr(158 + above, 228, y + 2, 0, 2) end end CopyTimer = (CopyTimer > 0) and CopyTimer - 1 or 0 if CopyTimer > 0 then local color = {1, 2, 3, 4, 4, 4, 4, 4, 4, 3, 2, 1} plus.pBorder("[!] Link pasted to console [!]", 120, 110, color[CopyTimer // 10 + 1], 0, false, 1, nil, true, true) end msgAnim(false, 0, true) return end end -- tic80 default function BOOT() math.randomseed(tstamp()) PalSaved = mpal.save() PalSavedHex = mpal.save(true) local mem = {{}, {}} for i = 1, 9 do mem[1][i] = "" for j = 1, 9 do mem[1][i] = mem[1][i]..i end mem[2][i] = toClass(i) end if pmem(10) == 0 then pmem(10, 1) lbit.boot(mem[1], false, 1) end lbit.setClass(mem[2], false, 1) end function TIC() UPDATE() DRAW() do -- cursor Mspt[3] = (mp) and 2 or 1 -- draw it if coli.touch(0, 0, 239, 135) then poke(0x03ffb, 0) if (pmem(0) == 0 and Menu ~= 2) or (Menu == 2 and (not coli.touch(121, 1, 238, 134) or not UsingCursor or AbovePopup or OBJ[ObjID].automove)) then spr(math.floor(Mspt[Mspt[3]]), mx - 3, my - 3, 6) end end -- sprite animation for i = 1, 2 do Mspt[i] = Mspt[i] + 0.1 if Mspt[i] >= 147.9 + 16 * (i - 1) then Mspt[i] = 144 + 16 * (i - 1) end end end end