Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- texter={}
- texter.lastcolor = "whol"
- function texter.Tchar(text,x,y,ptype)
- local mtx={}
- local voffset=0
- local hoffset=0
- mtx[1]={0,0,0}
- if text=="a" then
- mtx[1]={0,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,1,1}
- mtx[4]={1,0,1}
- mtx[5]={1,0,1}
- elseif text=="b" then
- mtx[1]={1,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,1,0}
- mtx[4]={1,0,1}
- mtx[5]={1,1,0}
- elseif text=="c" then
- mtx[1]={0,1,1}
- mtx[2]={1,0,0}
- mtx[3]={1,0,0}
- mtx[4]={1,0,0}
- mtx[5]={0,1,1}
- elseif text=="d" then
- mtx[1]={1,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,0,1}
- mtx[4]={1,0,1}
- mtx[5]={1,1,0}
- elseif text=="e" then
- mtx[1]={1,1,1}
- mtx[2]={1,0,0}
- mtx[3]={1,1,0}
- mtx[4]={1,0,0}
- mtx[5]={1,1,1}
- elseif text=="f" then
- mtx[1]={1,1,1}
- mtx[2]={1,0,0}
- mtx[3]={1,1,0}
- mtx[4]={1,0,0}
- mtx[5]={1,0,0}
- elseif text=="g" then
- mtx[1]={0,1,1,1}
- mtx[2]={1,0,0,0}
- mtx[3]={1,0,1,1}
- mtx[4]={1,0,0,1}
- mtx[5]={0,1,1,0}
- elseif text=="h" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={1,1,1}
- mtx[4]={1,0,1}
- mtx[5]={1,0,1}
- elseif text=="i" then
- mtx[1]={1,1,1}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={1,1,1}
- elseif text=="j" then
- mtx[1]={0,1}
- mtx[2]={0,1}
- mtx[3]={0,1}
- mtx[4]={0,1}
- mtx[5]={1,0}
- elseif text=="k" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={1,1,0}
- mtx[4]={1,0,1}
- mtx[5]={1,0,1}
- elseif text=="l" then
- mtx[1]={1,0,0}
- mtx[2]={1,0,0}
- mtx[3]={1,0,0}
- mtx[4]={1,0,0}
- mtx[5]={1,1,1}
- elseif text=="m" then
- mtx[1]={1,0,0,0,1}
- mtx[2]={1,1,0,1,1}
- mtx[3]={1,0,1,0,1}
- mtx[4]={1,0,0,0,1}
- mtx[5]={1,0,0,0,1}
- elseif text=="n" then
- mtx[1]={1,0,0,1}
- mtx[2]={1,1,0,1}
- mtx[3]={1,0,1,1}
- mtx[4]={1,0,0,1}
- mtx[5]={1,0,0,1}
- elseif text=="o" then
- mtx[1]={0,1,1,0}
- mtx[2]={1,0,0,1}
- mtx[3]={1,0,0,1}
- mtx[4]={1,0,0,1}
- mtx[5]={0,1,1,0}
- elseif text=="p" then
- mtx[1]={1,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,1,0}
- mtx[4]={1,0,0}
- mtx[5]={1,0,0}
- elseif text=="q" then
- mtx[1]={0,1,1,1,0}
- mtx[2]={1,0,0,0,1}
- mtx[3]={1,0,1,0,1}
- mtx[4]={1,0,0,1,0}
- mtx[5]={0,1,1,0,1}
- elseif text=="r" then
- mtx[1]={1,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,1,0}
- mtx[4]={1,0,1}
- mtx[5]={1,0,1}
- elseif text=="s" then
- mtx[1]={0,1,1}
- mtx[2]={1,0,0}
- mtx[3]={0,1,0}
- mtx[4]={0,0,1}
- mtx[5]={1,1,0}
- elseif text=="t" then
- mtx[1]={1,1,1}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={0,1,0}
- elseif text=="u" then
- mtx[1]={1,0,0,1}
- mtx[2]={1,0,0,1}
- mtx[3]={1,0,0,1}
- mtx[4]={1,0,0,1}
- mtx[5]={0,1,1,0}
- elseif text=="v" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={1,0,1}
- mtx[4]={1,0,1}
- mtx[5]={0,1,0}
- elseif text=="w" then
- mtx[1]={1,0,1,0,1}
- mtx[2]={1,0,1,0,1}
- mtx[3]={1,0,1,0,1}
- mtx[4]={1,0,1,0,1}
- mtx[5]={0,1,0,1,0}
- elseif text=="x" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={0,1,0}
- mtx[4]={1,0,1}
- mtx[5]={1,0,1}
- elseif text=="y" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={0,1,0}
- elseif text=="z" then
- mtx[1]={1,1,1}
- mtx[2]={0,0,1}
- mtx[3]={0,1,0}
- mtx[4]={1,0,0}
- mtx[5]={1,1,1}
- elseif text=="0" then
- mtx[1]={0,1,0}
- mtx[2]={1,0,1}
- mtx[3]={1,0,1}
- mtx[4]={1,0,1}
- mtx[5]={0,1,0}
- elseif text=="1" then
- mtx[1]={0,1,0}
- mtx[2]={1,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={1,1,1}
- elseif text=="2" then
- mtx[1]={1,1,0}
- mtx[2]={0,0,1}
- mtx[3]={0,1,0}
- mtx[4]={1,0,0}
- mtx[5]={1,1,1}
- elseif text=="3" then
- mtx[1]={1,1,0}
- mtx[2]={0,0,1}
- mtx[3]={0,1,0}
- mtx[4]={0,0,1}
- mtx[5]={1,1,0}
- elseif text=="4" then
- mtx[1]={1,0,1}
- mtx[2]={1,0,1}
- mtx[3]={1,1,1}
- mtx[4]={0,0,1}
- mtx[5]={0,0,1}
- elseif text=="5" then
- mtx[1]={1,1,1}
- mtx[2]={1,0,0}
- mtx[3]={1,1,0}
- mtx[4]={0,0,1}
- mtx[5]={1,1,0}
- elseif text=="6" then
- mtx[1]={0,1,1}
- mtx[2]={1,0,0}
- mtx[3]={1,1,0}
- mtx[4]={1,0,1}
- mtx[5]={0,1,0}
- elseif text=="7" then
- mtx[1]={1,1,1}
- mtx[2]={0,0,1}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={0,1,0}
- elseif text=="8" then
- mtx[1]={0,1,0}
- mtx[2]={1,0,1}
- mtx[3]={0,1,0}
- mtx[4]={1,0,1}
- mtx[5]={0,1,0}
- elseif text=="9" then
- mtx[1]={0,1,0}
- mtx[2]={1,0,1}
- mtx[3]={0,1,1}
- mtx[4]={0,0,1}
- mtx[5]={1,1,0}
- elseif text=="!" then
- mtx[1]={0,1,0}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,0,0}
- mtx[5]={0,1,0}
- elseif text=="(" then
- mtx[1]={0,0,1}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={0,0,1}
- elseif text==")" then
- mtx[1]={1,0,0}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={1,0,0}
- elseif text=="-" then
- mtx[1]={1,1,1}
- voffset=2
- elseif text=="_" then
- mtx[1]={1,1,1}
- voffset=4
- elseif text=="=" then
- mtx[1]={1,1,1}
- mtx[2]={0,0,0}
- mtx[3]={1,1,1}
- voffset=1
- elseif text=="+" then
- mtx[1]={0,1,0}
- mtx[2]={1,1,1}
- mtx[3]={0,1,0}
- voffset=1
- elseif text=="[" then
- mtx[1]={1,1,0}
- mtx[2]={1,0,0}
- mtx[3]={1,0,0}
- mtx[4]={1,0,0}
- mtx[5]={1,1,0}
- elseif text=="]" then
- mtx[1]={0,1,1}
- mtx[2]={0,0,1}
- mtx[3]={0,0,1}
- mtx[4]={0,0,1}
- mtx[5]={0,1,1}
- elseif text=="{" then
- mtx[1]={0,1,1}
- mtx[2]={0,1,0}
- mtx[3]={1,0,0}
- mtx[4]={0,1,0}
- mtx[5]={0,1,1}
- elseif text=="}" then
- mtx[1]={1,1,0}
- mtx[2]={0,1,0}
- mtx[3]={0,0,1}
- mtx[4]={0,1,0}
- mtx[5]={1,1,0}
- elseif text=="|" then
- mtx[1]={0,1,0}
- mtx[2]={0,1,0}
- mtx[3]={0,1,0}
- mtx[4]={0,1,0}
- mtx[5]={0,1,0}
- elseif text==":" then
- mtx[1]={0,0,0}
- mtx[2]={0,1,0}
- mtx[3]={0,0,0}
- mtx[4]={0,1,0}
- elseif text==";" then
- mtx[1]={0,1,0}
- mtx[2]={0,0,0}
- mtx[3]={0,1,0}
- mtx[4]={1,0,0}
- voffset=1
- elseif text=="\'" or text=="`" then
- mtx[1]={0,1,0}
- mtx[2]={0,1,0}
- voffset=-1
- elseif text=="\"" then
- mtx[1]={0,1,0,1}
- mtx[2]={0,1,0,1}
- voffset=-1
- elseif text=="," then
- mtx[1]={0,1,0}
- mtx[2]={1,0,0}
- voffset=4
- elseif text=="." then
- mtx[5]={1}
- voffset=4
- elseif text=="<" then
- mtx[1]={0,0,0,1}
- mtx[2]={0,0,1,0}
- mtx[3]={0,1,0,0}
- mtx[4]={0,0,1,0}
- mtx[5]={0,0,0,1}
- elseif text==">" then
- mtx[1]={0,1,0,0}
- mtx[2]={0,0,1,0}
- mtx[3]={0,0,0,1}
- mtx[4]={0,0,1,0}
- mtx[5]={0,1,0,0}
- elseif text=="/" then
- mtx[1]={0,0,0,0,1}
- mtx[2]={0,0,0,1,0}
- mtx[3]={0,0,1,0,0}
- mtx[4]={0,1,0,0,0}
- mtx[5]={1,0,0,0,0}
- elseif text=="\\" then
- mtx[1]={1,0,0,0,0}
- mtx[2]={0,1,0,0,0}
- mtx[3]={0,0,1,0,0}
- mtx[4]={0,0,0,1,0}
- mtx[5]={0,0,0,0,1}
- elseif text=="?" then
- mtx[1]={1,1,1}
- mtx[2]={0,0,1}
- mtx[3]={0,1,0}
- mtx[4]={0,0,0}
- mtx[5]={0,1,0}
- elseif text=="^" then
- mtx[1]={0,1,0}
- mtx[2]={1,0,1}
- elseif text=="#" then
- mtx[1]={0,1,0,1,0}
- mtx[2]={1,1,1,1,1}
- mtx[3]={0,1,0,1,0}
- mtx[4]={1,1,1,1,1}
- mtx[5]={0,1,0,1,0}
- elseif text=="$" then
- mtx[1]={0,0,1,0,0}
- mtx[2]={0,1,1,1,1}
- mtx[3]={1,0,1,0,0}
- mtx[4]={0,1,1,1,0}
- mtx[5]={0,0,1,0,1}
- mtx[6]={1,1,1,1,0}
- mtx[7]={0,0,1,0,0}
- voffset=-1
- elseif text=="%" then
- mtx[1]={1,1,0,0,1}
- mtx[2]={1,1,0,1,0}
- mtx[3]={0,0,1,0,0}
- mtx[4]={0,1,0,1,1}
- mtx[5]={1,0,0,1,1}
- elseif text=="&" then
- mtx[1]={0,0,1,1,1}
- mtx[2]={0,0,1,0,0}
- mtx[3]={0,1,1,1,1}
- mtx[4]={1,0,0,1,0}
- mtx[5]={0,1,1,0,1}
- elseif text=="@" then
- mtx[1]={0,1,1,1,1,1,0}
- mtx[2]={1,0,0,1,1,0,1}
- mtx[3]={1,0,1,0,1,0,1}
- mtx[4]={1,0,1,1,1,1,1}
- mtx[5]={1,0,0,0,0,0,0}
- mtx[6]={0,1,1,1,1,1,0}
- voffset=-1
- elseif text=="*" then
- mtx[1]={0,1,0,0,1,0}
- mtx[2]={0,0,1,1,0,0}
- mtx[3]={1,1,1,1,1,1}
- mtx[4]={0,0,1,1,0,0}
- mtx[5]={0,1,0,0,1,0}
- elseif text=="~" then
- mtx[1]={0,0,0,0,0,0}
- mtx[2]={0,0,0,0,0,0}
- mtx[3]={0,1,1,0,0,1}
- mtx[4]={1,0,0,1,1,0}
- elseif text==" " then
- mtx[1]={0,0,0}
- else --unknow character
- mtx[1]={1,1,1,1,1}
- mtx[2]={1,0,0,0,1}
- mtx[3]={1,0,0,0,1}
- mtx[4]={1,0,0,0,1}
- mtx[5]={1,1,1,1,1}
- end
- local height = # mtx
- local width = 3
- for i=1,height do
- if mtx[i]==nil then else
- width = # mtx[i]
- for j=1,width do
- if mtx[i][j]==1 then
- tpt.create(x+j-1+hoffset,y+i-1+voffset,ptype)
- end
- end
- end
- end
- return width
- end
- function texter.Tstr(text,x,y,ptype)
- local ox=0
- for i=1,string.len(text) do
- ox = 1 + ox + texter.Tchar(string.sub(string.lower(text),i,i),x+ox,y,ptype)
- end
- return string.len(text)
- end
- function T(text,ptype) -- Print one line to mouse position
- if ptype == nil then
- ptype = texter.lastcolor -- Use last used if not specified
- else
- texter.lastcolor = ptype -- Set last used if specified
- end
- texter.Tstr(text,tpt.mousex,tpt.mousey,ptype)
- return string.len(text)
- end
- function Txy(text,x,y,ptype) -- Print one line to x, y (Same as texter.Tstr, but uses last colour)
- if ptype == nil then
- ptype = texter.lastcolor
- else
- texter.lastcolor = ptype
- end
- texter.Tstr(text,x,y,ptype)
- end
- function Tlines(startx, starty, ...) -- Print multiple lines split by comma
- if starty + arg.n * 6 > 383 then -- Start Y + amount of lines * line width
- tpt.log("Too many lines to fit on screen!")
- return
- end
- local curr_string = "" -- Current line
- local curr_liney = 0 -- Current Y position.
- for i=1, arg.n, 1 do
- curr_liney = starty + i * 6 -- One line is 6px wide.
- curr_string = arg[i]
- Txy(curr_string, startx, curr_liney)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement