Advertisement
Guest User

1

a guest
Jul 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.01 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,"Anzahl: "..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.            Button[3][7] = "Anzahl: "..Tscale
  113.            Button[3][8] = false
  114.          end
  115.        end
  116.      end
  117.    end
  118. end  
  119.  
  120.  
  121. while true do
  122.   Background(1,xMax,1,yMax,Bcol)
  123.   JoJa(xMax/2-7,1)
  124.   term.setTextColor(colors.white)
  125.   printButton()
  126.   event,_,xPos,yPos = os.pullEvent("mouse_click")
  127.   checkButton(xPos,yPos)
  128.   if Button[5][10] then
  129.     printer.newPage()
  130.     xMaxP,yMaxP = printer.getPageSize()
  131.     Background(1,xMax,1,yMax,Bcol)
  132.     JoJa(xMax/2-7,1)
  133.     Background(2,xMax-1,3,3,colors.black)
  134.     term.setTextColor(colors.white)
  135.     term.setCursorPos(2,3)
  136.     term.write("Titel: ")
  137.     titel = io.read()  
  138.     Background(1,xMax,1,yMax,Bcol)
  139.     JoJa(xMax/2-7,1)
  140.     Background(2,xMax-1,3,3,colors.black)
  141.     term.setTextColor(colors.white)
  142.     term.setCursorPos(2,3)
  143.     term.write("Ueberschrift: ")
  144.     uebers = io.read()
  145.     Background(1,xMax,1,yMax,Bcol)
  146.     JoJa(xMax/2-7,1)
  147.     Background(2,xMax-1,3,3,colors.black)
  148.     term.setTextColor(colors.white)
  149.     term.setCursorPos(2,3)
  150.     term.write("Autor: ")
  151.     autor = io.read()
  152.     Background(1,xMax,1,yMax,Bcol)
  153.     JoJa(xMax/2-7,1)  
  154.     Background(2,xMaxP+4,3,yMax-1,colors.black)
  155.     Zeile = {}
  156.     for i = 1,16 do
  157.      term.setCursorPos(2,2+i)
  158.      term.write(i..":")
  159.      term.setCursorPos(5,2+i)
  160.      Zeile[i] = io.read()
  161.     end
  162.     for b = 1,Tscale do
  163.       printer.setCursorPos(1,1)
  164.       printer.write(uebers)
  165.       printer.setPageTitle(titel)
  166.       for i = 1,#Zeile do
  167.         printer.setCursorPos(1,2+i)
  168.         printer.write(Zeile[i])
  169.       end
  170.       printer.setCursorPos(1,20)
  171.       printer.write("gez. "..autor)
  172.       printer.endPage()
  173.       printer.newPage()
  174.     end
  175.     printer.setCursorPos(1,1)
  176.     printer.write("Auftrag:")
  177.     printer.setCursorPos(1,3)
  178.     printer.write("gedruckte Seiten: "..Tscale)
  179.     printer.setCursorPos(1,4)
  180.     printer.write("Titel: "..titel)
  181.     printer.setCursorPos(1,5)
  182.     printer.write("Ueberschrift: "..uebers)
  183.     printer.setCursorPos(1,6)
  184.     printer.write("Autor: "..autor)
  185.     printer.endPage()
  186.   end
  187. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement