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