Nike622000

Drucker

Feb 21st, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.61 KB | None | 0 0
  1. local printerSide = "left"
  2. local BundledSide = "back"
  3. local Bcol        = colors.lightGray
  4.  
  5. local printer     = peripheral.wrap(printerSide)
  6. local xMax,yMax   = term.getSize()
  7. local Tscale      = 1
  8. local col         = 0
  9.  
  10. Button    = {}
  11. Button[1] = {2,xMax/2-1,3,5,colors.blue,colors.red,"Bunt",false}
  12. Button[2] = {xMax/2+1,xMax,3,5,colors.blue,colors.black,"SW",false}
  13. Button[3] = {2,xMax-1,7,9,colors.blue,colors.blue,"Textgroesse: "..Tscale,false}
  14. Button[4] = {2,xMax/2-1,11,13,colors.gray,colors.blue,"Farbe",false}
  15. Button[5] = {2,xMax-1,15,17,colors.gray,colors.blue,"Drucken",false}
  16.  
  17. function JoJa(xP,yP)
  18.   term.setCursorPos(xP,yP)
  19.   term.setBackgroundColor(colors.gray)
  20.   term.setTextColor(colors.cyan)
  21.   term.write("Jo")
  22.   term.setTextColor(colors.orange)
  23.   term.write("Ja ")
  24.   term.setTextColor(colors.lightGray)
  25.   term.write("Productions")
  26. end
  27.  
  28. function Background(xP1,xP2,yP1,yP2,col)
  29.   term.setBackgroundColor(col)
  30.   for xP = xP1,xP2 do
  31.     for yP = yP1,yP2 do
  32.       term.setCursorPos(xP,yP)
  33.       term.write(" ")
  34.     end
  35.   end
  36. end
  37.  
  38. function printButton()
  39.   for i = 1,#Button do
  40.     if Button[i][9] == nil then
  41.       term.setTextColor(colors.white)
  42.     else
  43.       term.setTextColor(Button[i][9])
  44.     end
  45.     if  Button[i][8] then
  46.       term.setBackgroundColor(Button[i][6])
  47.     else
  48.       term.setBackgroundColor(Button[i][5])
  49.     end
  50.     for xP = Button[i][1],Button[i][2] do
  51.       for yP = Button[i][3],Button[i][4] do
  52.         term.setCursorPos(xP,yP)
  53.         term.write(" ")
  54.       end
  55.     end
  56.     term.setCursorPos(((Button[i][1]+Button[i][2])/2)-(#Button[i][7]/2)+1,(Button[i][3]+Button[i][4])/2)
  57.     term.write(Button[i][7])
  58.   end
  59. end
  60.  
  61. function checkButton(xP,yP)
  62.   for i = 1,#Button do
  63.     if xP >= Button[i][1] and xP <= Button[i][2] and
  64.        yP >= Button[i][3] and yP <= Button[i][4] then
  65.        if i == 4 then
  66.          if Button[1][8] then
  67.            col = col+1
  68.            if col == 11 then
  69.              Button[4][6] = colors.cyan
  70.            else
  71.              Button[4][6] = colors.blue
  72.            end
  73.            if col > 15 then
  74.              col = 0
  75.            end
  76.            Button[4][9] = 2^col
  77.          end
  78.        elseif i == 5 then
  79.          if Button[1][8] or Button[2][8] then
  80.            Button[5][10] = true
  81.          end
  82.        else
  83.          if Button[i][8] then
  84.            Button[i][8] = false
  85.          else
  86.            Button[i][8] = true
  87.          end
  88.        end
  89.        --
  90.        if i == 1 then
  91.          if Button[1][8] then
  92.            Button[4][8] = true
  93.            Button[2][8] = false
  94.          end
  95.        end
  96.        if i == 2 then
  97.          if Button[2][8] then
  98.            Button[4][8] = false
  99.            Button[1][8] = false
  100.            Button[4][9] = 1
  101.          end
  102.        end
  103.        if Button[1][8] or Button[2][8] then
  104.          Button[5][8] = true
  105.        else
  106.          Button[5][8] = false
  107.        end
  108.        --
  109.        if i == 3 then
  110.          if Button[3][8] then
  111.            Tscale = Tscale+1
  112.            if Tscale > 5 then
  113.              Tscale = 1
  114.            end
  115.            Button[3][7] = "Textgroesse: "..Tscale
  116.            Button[3][8] = false
  117.          end
  118.        end
  119.      end
  120.    end
  121. end  
  122.  
  123.  
  124. while true do
  125.   Background(1,xMax,1,yMax,Bcol)
  126.   JoJa(xMax/2-7,1)
  127.   term.setTextColor(colors.white)
  128.   printButton()
  129.   event,_,xPos,yPos = os.pullEvent("mouse_click")
  130.   checkButton(xPos,yPos)
  131.   if Button[5][10] then
  132.     Background(1,xMax,1,yMax,Bcol)
  133.     JoJa(xMax/2-7,1)
  134.     Background(2,xMax-1,3,3,colors.black)
  135.     term.setTextColor(colors.white)
  136.     term.setCursorPos(2,3)
  137.     term.write("Titel: ")
  138.     titel = io.read()  
  139.     Background(1,xMax,1,yMax,Bcol)
  140.     JoJa(xMax/2-7,1)
  141.     Background(2,xMax-1,3,3,colors.black)
  142.     term.setTextColor(colors.white)
  143.     term.setCursorPos(2,3)
  144.     term.write("Ueberschrift: ")
  145.     uebers = io.read()
  146.     Background(1,xMax,1,yMax,Bcol)
  147.     JoJa(xMax/2-7,1)
  148.     Background(2,xMax-1,3,3,colors.black)
  149.     term.setTextColor(colors.white)
  150.     term.setCursorPos(2,3)
  151.     term.write("Autor: ")
  152.     autor = io.read()
  153.     Background(1,xMax,1,yMax,Bcol)
  154.     JoJa(xMax/2-7,1)  
  155.     Background(2,xMax-1,3,yMax-1,colors.black)
  156.     Zeile = {}
  157.     for i = 1,16 do
  158.      term.setCursorPos(2,2+i)
  159.      term.write(i..":")
  160.      term.setCursorPos(5,2+i)
  161.      Zeile[i] = io.read()
  162.     end
  163.     printer.newPage()
  164.     printer.setCursorPos(1,1)
  165.     printer.write(uebers)
  166.     printer.setPageTitle(titel)
  167.     for i = 1,#Zeile do
  168.       printer.setCursorPos(1,2+i)
  169.       printer.write(Zeile[i])
  170.     end
  171.     printer.setCursorPos(1,20)
  172.     printer.write("gez. "..autor)
  173.     printer.endPage()
  174.   end
  175. end
Add Comment
Please, Sign In to add comment