Advertisement
jamawie

Word 2.0

May 4th, 2016
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.02 KB | None | 0 0
  1. mon = peripheral.wrap("right")
  2. x,y = mon.getSize()
  3. colors = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
  4.  
  5. function drawTitle()
  6.   string = "  C T - W o r d  "
  7.   xstart = math.floor((x-#string)/2)
  8.   mon.setBackgroundColor(2048)
  9.   mon.setTextColor(1)
  10.   mon.setCursorPos(xstart,1)
  11.   mon.write(string)
  12.   mon.setBackgroundColor(32768)
  13.   mon.setTextColor(1)
  14. end
  15.  
  16. function drawPage()
  17.   for i=3,26 do
  18.     mon.setCursorPos(1,i)
  19.     if i==3 or i==26 then
  20.       mon.write("+")
  21.     else
  22.       mon.write("|")
  23.     end
  24.     sleep(0.1)
  25.   end
  26.   for i=3,26 do
  27.     mon.setCursorPos(27,i)
  28.     if i==3 or i==26 then
  29.       mon.write("+")
  30.     else
  31.       mon.write("|")
  32.     end
  33.     sleep(0.1)
  34.   end
  35.   for i=1,27 do
  36.     mon.setCursorPos(i,3)
  37.     if i==1 or i==27 then
  38.       mon.write("+")
  39.     else
  40.       mon.write("-")
  41.     end
  42.     sleep(0.1)
  43.   end
  44.   for i=1,27 do
  45.     mon.setCursorPos(i,26)
  46.     if i==1 or i==27 then
  47.       mon.write("+")
  48.     else
  49.       mon.write("-")
  50.     end
  51.     sleep(0.1)
  52.   end
  53. end
  54.  
  55. function drawOptions()
  56.   ystart = math.floor((y-16)/2)
  57.   for i=1,#colors do
  58.     mon.setCursorPos(x-1,ystart+i)
  59.     mon.setBackgroundColor(colors[i])
  60.     mon.write("  ")
  61.     sleep(0.1)
  62.   end
  63.   mon.setBackgroundColor(32768)
  64.   mon.setCursorPos(x-3,ystart+1)
  65.   mon.setBackgroundColor(512)
  66.   mon.write("T")
  67. end
  68.  
  69. function drawInfo(ln1,ln2,ln3)
  70.   ystart = math.floor((y-4)/2)
  71.  
  72.   mon.setTextColor(1)
  73.   mon.setBackgroundColor(512)
  74.   for i=ystart,ystart+4 do
  75.     mon.setCursorPos(3,i)
  76.     for j=3,x-3 do
  77.       mon.write(" ")
  78.     end
  79.   end
  80.   for i=ystart,ystart+4 do
  81.     mon.setCursorPos(3,i)
  82.     if i==ystart or i==ystart+4 then
  83.       for j=3,x-3 do
  84.         if j==3 or j==x-3 then
  85.           mon.write("+")
  86.         else
  87.           mon.write("-")
  88.         end
  89.       end
  90.     else
  91.       mon.setCursorPos(3,i)
  92.       mon.write("|")
  93.       mon.setCursorPos(x-3,i)
  94.       mon.write("|")
  95.     end
  96.   end
  97.   xstart = math.floor(((x-6)-#ln1)/2)
  98.   mon.setCursorPos(5+xstart,ystart+1)
  99.   mon.write(ln1)
  100.   xstart = math.floor(((x-6)-#ln2)/2)
  101.   mon.setCursorPos(5+xstart,ystart+2)
  102.   mon.write(ln2)
  103.   xstart = math.floor(((x-6)-#ln3)/2)
  104.   mon.setCursorPos(5+xstart,ystart+3)
  105.   mon.write(ln3)
  106. end
  107.  
  108. function drawWarning(ln1,ln2,ln3)
  109.   ystart = math.floor((y-4)/2)
  110.  
  111.   mon.setTextColor(1)
  112.   mon.setBackgroundColor(2)
  113.   for i=ystart,ystart+4 do
  114.     mon.setCursorPos(3,i)
  115.     for j=3,x-3 do
  116.       mon.write(" ")
  117.     end
  118.   end
  119.   for i=ystart,ystart+4 do
  120.     mon.setCursorPos(3,i)
  121.     if i==ystart or i==ystart+4 then
  122.       for j=3,x-3 do
  123.         if j==3 or j==x-3 then
  124.           mon.write("+")
  125.         else
  126.           mon.write("-")
  127.         end
  128.       end
  129.     else
  130.       mon.setCursorPos(3,i)
  131.       mon.write("|")
  132.       mon.setCursorPos(x-3,i)
  133.       mon.write("|")
  134.     end
  135.   end
  136.   xstart = math.floor(((x-6)-#ln1)/2)
  137.   mon.setCursorPos(5+xstart,ystart+1)
  138.   mon.write(ln1)
  139.   xstart = math.floor(((x-6)-#ln2)/2)
  140.   mon.setCursorPos(5+xstart,ystart+2)
  141.   mon.write(ln2)
  142.   xstart = math.floor(((x-6)-#ln3)/2)
  143.   mon.setCursorPos(5+xstart,ystart+3)
  144.   mon.write(ln3)
  145. end
  146.  
  147. function drawError(ln1,ln2,ln3)
  148.   ystart = math.floor((y-4)/2)
  149.  
  150.   mon.setTextColor(1)
  151.   mon.setBackgroundColor(16384)
  152.   for i=ystart,ystart+4 do
  153.     mon.setCursorPos(3,i)
  154.     for j=3,x-3 do
  155.       mon.write(" ")
  156.     end
  157.   end
  158.   for i=ystart,ystart+4 do
  159.     mon.setCursorPos(3,i)
  160.     if i==ystart or i==ystart+4 then
  161.       for j=3,x-3 do
  162.         if j==3 or j==x-3 then
  163.           mon.write("+")
  164.         else
  165.           mon.write("-")
  166.         end
  167.       end
  168.     else
  169.       mon.setCursorPos(3,i)
  170.       mon.write("|")
  171.       mon.setCursorPos(x-3,i)
  172.       mon.write("|")
  173.     end
  174.   end
  175.   xstart = math.floor(((x-6)-#ln1)/2)
  176.   mon.setCursorPos(5+xstart,ystart+1)
  177.   mon.write(ln1)
  178.   xstart = math.floor(((x-6)-#ln2)/2)
  179.   mon.setCursorPos(5+xstart,ystart+2)
  180.   mon.write(ln2)
  181.   xstart = math.floor(((x-6)-#ln3)/2)
  182.   mon.setCursorPos(5+xstart,ystart+3)
  183.   mon.write(ln3)
  184. end
  185.  
  186. --main program
  187. drawTitle()
  188. drawPage()
  189. drawOptions()
  190. drawInfo("Testinfo","Du kannst dich nun gut","informiert fuehlen.")
  191. sleep(2)
  192. drawWarning("Testwarnung","Dies ist ein Test","Bitte ruhig bleiben.")
  193. sleep(2)
  194. drawError("Testfehler","Dies ist ein Fehler! Vorsicht!",">> Explosionsgefahr <<")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement