Advertisement
Guest User

startup

a guest
Mar 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. moni=peripheral.find("monitor")
  2. moni.setTextScale(2)
  3. testE=fs.exists("MoniNachricht")
  4. testZ=fs.exists("MoniFarbe")
  5. knopf={{1,3,"Neue Nachricht",colors.blue},
  6.        {1,7,"F",colors.white,2},
  7.        {5,7,"F",colors.orange,3},
  8.        {9,7,"F",colors.magenta,4},
  9.        {1,9,"F",colors.lightBlue,5},
  10.        {5,9,"F",colors.yellow,6},
  11.        {9,9,"F",colors.lime,7},
  12.        {1,11,"F",colors.pink,8},
  13.        {5,11,"F",colors.gray,9},
  14.        {9,11,"F",colors.lightGray,10},
  15.        {1,13,"F",colors.cyan,11},
  16.        {5,13,"F",colors.purple,12},
  17.        {9,13,"F",colors.blue,13},
  18.        {1,15,"F",colors.brown,14},
  19.        {5,15,"F",colors.green,15},
  20.        {9,15,"F",colors.red,16}}
  21.        
  22. if testE then
  23.  
  24. else
  25.   a=fs.open("MoniNachricht","w")
  26.   a.write("Nachricht")
  27.   a.close()
  28. end
  29. if testZ then
  30.  
  31. else
  32.   a=fs.open("MoniFarbe","w")
  33.   a.write("2")
  34.   a.close()
  35. end
  36.  
  37. function button(tex,farb)
  38.   term.setTextColor(colors.lightGray)
  39.   term.write("[")
  40.   term.setTextColor(farb)
  41.   term.write(tex)
  42.   term.setTextColor(colors.lightGray)
  43.   term.write("]")
  44. end
  45.  
  46. function start()
  47. while true do
  48.   term.clear()
  49.   term.setCursorPos(1,1)
  50.   term.setTextColor(colors.white)
  51.   write("Monitor-Schleifenprogramm")
  52.   term.setCursorPos(1,5)
  53.   write("Farben")
  54.   for i=1, #knopf do
  55.     term.setCursorPos(knopf[i][1],knopf[i][2])
  56.     button(knopf[i][3],knopf[i][4])
  57.   end
  58.   eve={os.pullEvent()}
  59.   if eve[1]=="mouse_click" then
  60.     if eve[4]==3 and eve[3]>0 and eve[3]<17 then
  61.       new()
  62.     end
  63.    
  64.     for i=1, #knopf do
  65.       anfang=knopf[i][1]
  66.       ende=anfang+2
  67.       if eve[4]==knopf[i][2] and eve[3]>anfang and eve[3]<ende then
  68.         fa=fs.open("MoniFarbe","w")
  69.         fa.write(knopf[i][5])
  70.         fa.close()
  71.       end
  72.     end
  73.   end
  74. end
  75. end
  76.  
  77. function new()
  78.   term.clear()
  79.   term.setCursorPos(1,1)
  80.   write("Neue Nachricht:")
  81.   text=read()
  82.   TX=fs.open("MoniNachricht","w")
  83.   TX.write(text)
  84.   TX.close()
  85. end
  86.  
  87. function wait()
  88.   sleep(30)
  89. end
  90.  
  91. function mon()
  92.   while true do
  93.     moni.setTextScale(5)
  94.     e,s=moni.getSize()
  95.     e=e+1
  96.     nach=fs.open("MoniNachricht","r")
  97.     text=nach.readAll()
  98.     nach.close()
  99.     fa=fs.open("MoniFarbe","r")
  100.     farbe=fa.readAll()
  101.     fa.close()
  102.     farbe=farbe+0
  103.     te=text
  104.     zahl=0
  105.     for i=1, #te do
  106.       te:gsub(i,i)
  107.       zahl=zahl+1
  108.     end
  109.     s=s-zahl
  110.     moni.setTextColor(knopf[farbe][4])
  111.     while e>s do
  112.       moni.clear()
  113.       moni.setCursorPos(e,1)
  114.       moni.write(text)
  115.       e=e-1
  116.       sleep(0.5)
  117.     end
  118.   end
  119. end
  120.  
  121. parallel.waitForAll(start,mon)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement