Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TableCHar
- -- by skypop
- -- pastebin get vpu8E2nP tablechar
- local couleur = ...
- if not couleur or couleur=="black" then
- couleur = false
- else
- couleur = true
- end
- local printer = peripheral.find("printer")
- if not printer.newPage() then
- error("Can't print now",-1)
- return
- end
- if not couleur then
- printer.setCursorPos(1,1)
- printer.write(" --- ")
- printer.setCursorPos(1,2)
- printer.write(" Table de caractères ")
- printer.setCursorPos(1,3)
- printer.write(" par SukaiPoppuGõ")
- printer.setCursorPos(1,4)
- printer.write(" Usage:")
- printer.setCursorPos(1,5)
- printer.write(" string.char(n)")
- printer.setCursorPos(1,6)
- printer.write(" \"n\" le n° du caractère")
- end
- printer.setPageTitle("Table de caractères")
- local x,y=1,8
- local w,h = 25,21
- function pad(n)
- local str=""
- if n<10 then str=" "..str end
- if n<100 then str=" "..str end
- return str..tostring(math.floor(n))
- end
- --for y=1,h do
- -- term.setCursorPos(1,y)
- -- term.write(string.rep(string.char(127),w))
- -- if h<=21 then
- -- term.setCursorPos(1,y)
- -- term.write(string.rep(" ",25))
- -- end
- --end
- --term.setCursorPos(1,1)
- local c,s,p=1,"",1
- for c=1,255 do
- if y > h then
- printer.endPage()
- y=1
- p=p+1
- if not printer.newPage() then
- error("Can't print more",-1)
- return
- end
- printer.setPageTitle("Tbl chars - page "..p)
- end
- if string.len(s)>25-6 then
- printer.setCursorPos(1,y)
- if (couleur and y%2==0)
- or (not couleur and y%2==1) then
- printer.write(s)
- end
- print(s)
- y=y+1
- s = ""
- end
- if not string.char(c) then
- printer.setCursorPos(1,y)
- if (couleur and y%2==0)
- or (not couleur and y%2==1) then
- printer.write(s)
- end
- y=y+1
- s = ""
- break
- end
- s = s..pad(c).." "..string.char(c).." "
- end
- term.setCursorPos(26,1)
- if string.len(s)>0 then
- if y>h then
- printer.endPage()
- y=1
- if not printer.startPage() then
- error("Can't print last line",-1)
- return
- end
- p = p+1
- printer.setpageTitle("Tbl chars - page "..p)
- end
- printer.setCursorPos(1,y)
- if (couleur and y%2==0)
- or (not couleur and y%2==1) then
- printer.write(s)
- end
- end
- printer.endPage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement