MagmaLP

Untitled

Mar 28th, 2022 (edited)
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. function calc_color(textcolor)
  2.     return math.pow(2, textcolor - 1)
  3. end
  4.  
  5. function m(gap, line, textcolor, background, text)
  6.     mon.setBackgroundColor(calc_color(background))
  7.     mon.setCursorPos(gap,line)
  8.     mon.setTextColor(calc_color(textcolor))
  9.     text = mon.write(text)
  10. end
  11.  
  12. function t(gap, line, textcolor, background, text)
  13.     term.setBackgroundColor(calc_color(background))
  14.     term.setCursorPos(gap,line)
  15.     term.setTextColor(calc_color(textcolor))
  16.     text = term.write(text)
  17. end
  18.  
  19. --term("1,1,"Monitor Seite")
  20. --side = read()
  21. side = "right"
  22. mon = peripheral.wrap(side)
  23. mon.setTextScale(1)
  24.  
  25. term.clear()
  26. t(01,01,06,16,"Schriftgrösse wählen, drück auf den Button um       ")
  27. t(01,02,06,16,"auf dem Monitor ein Beispiel zu sehen.")
  28.  
  29. function DrawTextScaleButtons()
  30.     a = 1
  31.     for c = 3,31,7 do
  32.         t(c,04,01,15,"  "..a.."  ")
  33.         a = a + 1
  34.     end
  35.     a = 1.5
  36.     for c = 3,24,7 do
  37.         t(c,06,01,15," "..a.." ")
  38.         a = a + 1
  39.     end
  40.     t(03,08,01,15," bestätigen ")
  41.     monsize()
  42.     TextScale()
  43. end
  44.  
  45. function monsize()
  46.     mon.setTextColor(1)
  47.     b = 1
  48.     for a = 1,99 do
  49.         mon.setCursorPos(1,a)
  50.         if b == 10 then
  51.             mon.setCursorPos(1,b)
  52.             b = 1
  53.         else
  54.             mon.write(b.."  ")
  55.             b = b + 1
  56.         end
  57.     end
  58.     b = 1
  59.     for a = 1,99 do
  60.         mon.setCursorPos(a,1)
  61.         if b == 10 then
  62.             b = 1
  63.         else
  64.             mon.write(b)
  65.             b = b + 1
  66.         end
  67.     end
  68. end
  69.  
  70. function TextScale()
  71.     local event, button, X, Y = os.pullEvent("mouse_click")
  72.     if X >= 03 and X <= 07 and Y == 4 and side == side then -- 1
  73.         mon.setTextScale(1)
  74.         monsize()
  75.         m(02,02,06,16,"Beispieltext")
  76.         TextScale()
  77.     elseif X >= 10 and X <= 14 and Y == 4 and side == side then -- 2
  78.         mon.setTextScale(2)
  79.         monsize()
  80.         m(02,02,06,16,"Beispieltext")
  81.         TextScale()
  82.     elseif X >= 17 and X <= 21 and Y == 4 and side == side then -- 3
  83.         mon.setTextScale(3)
  84.         monsize()
  85.         m(02,02,06,16,"Beispieltext")
  86.         TextScale()
  87.     elseif X >= 24 and X <= 28 and Y == 4 and side == side then -- 4
  88.         mon.setTextScale(4)
  89.         monsize()
  90.         m(02,02,06,16,"Beispieltext")
  91.         TextScale()
  92.     elseif X >= 31 and X <= 35 and Y == 4 and side == side then -- 5
  93.         mon.setTextScale(5)
  94.         monsize()
  95.         m(02,02,06,16,"Beispieltext")
  96.         TextScale()
  97.     elseif X >= 03 and X <= 07 and Y == 6 and side == side then -- 1.5
  98.         mon.setTextScale(1.5)
  99.         monsize()
  100.         m(02,02,06,16,"Beispieltext")
  101.         TextScale()
  102.     elseif X >= 10 and X <= 14 and Y == 6 and side == side then -- 2.5
  103.         mon.setTextScale(2.5)
  104.         monsize()
  105.         m(02,02,06,16,"Beispieltext")
  106.         TextScale()
  107.     elseif X >= 17 and X <= 21 and Y == 6 and side == side then -- 3.5
  108.         mon.setTextScale(3.5)
  109.         monsize()
  110.         m(02,02,06,16,"Beispieltext")
  111.         TextScale()
  112.     elseif X >= 24 and X <= 28 and Y == 6 and side == side then -- 4.5
  113.         mon.setTextScale(4.5)
  114.         monsize()
  115.         m(02,02,06,16,"Beispieltext")
  116.         TextScale()
  117.     elseif X >= 03 and X <= 14 and Y == 8 and side == side then -- bestätigen
  118.         term.clear()
  119.     else
  120.         TextScale()
  121.         sleep(0.5)
  122.     end    
  123. end
  124.  
  125. DrawTextScaleButtons()
Add Comment
Please, Sign In to add comment