SHOW:
|
|
- or go back to the newest paste.
| 1 | -- TableCHar | |
| 2 | -- by skypop | |
| 3 | -- pastebin get vpu8E2nP tablechar | |
| 4 | ||
| 5 | local couleur = ... | |
| 6 | ||
| 7 | if not couleur or couleur=="black" then | |
| 8 | couleur = false | |
| 9 | - | -- Syntax: Brainfuck |
| 9 | + | |
| 10 | - | local printer = peripheral.wrap("printer_39")
|
| 10 | + | |
| 11 | end | |
| 12 | ||
| 13 | local printer = peripheral.find("printer")
| |
| 14 | ||
| 15 | if not printer.newPage() then | |
| 16 | error("Can't print now",-1)
| |
| 17 | return | |
| 18 | end | |
| 19 | ||
| 20 | if not couleur then | |
| 21 | printer.setCursorPos(1,1) | |
| 22 | printer.write(" --- ")
| |
| 23 | printer.setCursorPos(1,2) | |
| 24 | printer.write(" Table de caractères ")
| |
| 25 | printer.setCursorPos(1,3) | |
| 26 | printer.write(" par SukaiPoppuGõ")
| |
| 27 | printer.setCursorPos(1,4) | |
| 28 | printer.write(" Usage:")
| |
| 29 | printer.setCursorPos(1,5) | |
| 30 | printer.write(" string.char(n)")
| |
| 31 | printer.setCursorPos(1,6) | |
| 32 | printer.write(" \"n\" le n° du caractère")
| |
| 33 | end | |
| 34 | printer.setPageTitle("Table de caractères")
| |
| 35 | ||
| 36 | local x,y=1,8 | |
| 37 | local w,h = 25,21 | |
| 38 | function pad(n) | |
| 39 | local str="" | |
| 40 | if n<10 then str=" "..str end | |
| 41 | if n<100 then str=" "..str end | |
| 42 | return str..tostring(math.floor(n)) | |
| 43 | end | |
| 44 | ||
| 45 | --for y=1,h do | |
| 46 | -- term.setCursorPos(1,y) | |
| 47 | -- term.write(string.rep(string.char(127),w)) | |
| 48 | -- if h<=21 then | |
| 49 | -- term.setCursorPos(1,y) | |
| 50 | -- term.write(string.rep(" ",25))
| |
| 51 | -- end | |
| 52 | --end | |
| 53 | --term.setCursorPos(1,1) | |
| 54 | ||
| 55 | local c,s,p=1,"",1 | |
| 56 | for c=1,255 do | |
| 57 | if y > h then | |
| 58 | printer.endPage() | |
| 59 | y=1 | |
| 60 | p=p+1 | |
| 61 | if not printer.newPage() then | |
| 62 | error("Can't print more",-1)
| |
| 63 | return | |
| 64 | end | |
| 65 | printer.setPageTitle("Tbl chars - page "..p)
| |
| 66 | end | |
| 67 | if string.len(s)>25-6 then | |
| 68 | printer.setCursorPos(1,y) | |
| 69 | if (couleur and y%2==0) | |
| 70 | or (not couleur and y%2==1) then | |
| 71 | printer.write(s) | |
| 72 | end | |
| 73 | print(s) | |
| 74 | y=y+1 | |
| 75 | s = "" | |
| 76 | end | |
| 77 | if not string.char(c) then | |
| 78 | printer.setCursorPos(1,y) | |
| 79 | if (couleur and y%2==0) | |
| 80 | or (not couleur and y%2==1) then | |
| 81 | printer.write(s) | |
| 82 | end | |
| 83 | y=y+1 | |
| 84 | s = "" | |
| 85 | break | |
| 86 | end | |
| 87 | s = s..pad(c).." "..string.char(c).." " | |
| 88 | end | |
| 89 | term.setCursorPos(26,1) | |
| 90 | if string.len(s)>0 then | |
| 91 | if y>h then | |
| 92 | printer.endPage() | |
| 93 | y=1 | |
| 94 | if not printer.startPage() then | |
| 95 | error("Can't print last line",-1)
| |
| 96 | return | |
| 97 | end | |
| 98 | p = p+1 | |
| 99 | printer.setpageTitle("Tbl chars - page "..p)
| |
| 100 | end | |
| 101 | printer.setCursorPos(1,y) | |
| 102 | if (couleur and y%2==0) | |
| 103 | or (not couleur and y%2==1) then | |
| 104 | printer.write(s) | |
| 105 | end | |
| 106 | end | |
| 107 | ||
| 108 | printer.endPage() |