Advertisement
MC403

redstonemgr

Jun 22nd, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.78 KB | None | 0 0
  1. --SJNOS redstonemgr.exe by MC403
  2.  
  3. local red_active = true
  4. local slc = 0
  5.  
  6. outputs = {"Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off","Off"}
  7. color = {colors.red,colors.orange,colors.yellow,colors.lime,colors.green,colors.cyan,colors.lightBlue,colors.blue,colors.purple,colors.magenta,colors.pink,colors.brown,colors.white,colors.lightGray,colors.gray,colors.black}
  8.  
  9. function clear()
  10.   term.clear()
  11.   term.setCursorPos(1,1)
  12. end
  13.  
  14. function drawIcon(x,y,color)
  15.   term.setBackgroundColor(color)
  16.   for i=0,3 do
  17.     term.setCursorPos(x,y+i)
  18.     print("      ")
  19.   end
  20. end
  21.  
  22. function drawIcons()
  23.   local result = 0
  24.   for i=0,1 do
  25.     for j=0,7 do
  26.       drawIcon(j*6+2,i*4+3,color[i*8+(j+1)])
  27.       if outputs[i*8+(j+1)]=="On" then
  28.         result = result + color[i*8+(j+1)]
  29.       end
  30.     end
  31.   end
  32.  
  33.   rs.setBundledOutput("back",result)
  34.  
  35.   term.setTextColor(colors.black)
  36.   term.setBackgroundColor(colors.white)
  37.   for i=0,1 do
  38.     for j=0,7 do
  39.       term.setCursorPos(j*6+3,i*4+4)
  40.       print(outputs[i*8+(j+1)])
  41.     end
  42.   end
  43.  
  44.   term.setCursorPos(20,16)
  45.   term.setTextColor(colors.cyan)
  46.   term.setBackgroundColor(colors.white)
  47.   print("Select all ")
  48.   term.setCursorPos(20,17)
  49.   print("Select none")
  50.   term.setCursorPos(20,18)
  51.   print("Lightshow  ")
  52.  
  53. end
  54.  
  55. function drawTitle()
  56.   term.setCursorPos(1,1)
  57.   term.setTextColor(colors.white)
  58.   term.setBackgroundColor(colors.cyan)
  59.   term.clearLine()
  60.   print(" Redstone")
  61.   term.setBackgroundColor(colors.red)
  62.   term.setTextColor(colors.black)
  63.   term.setCursorPos(51,1)
  64.   print("X")
  65.   term.setBackgroundColor(colors.white)
  66. end
  67.  
  68. function showStartMenu()
  69.   term.setBackgroundColor(colors.blue)
  70.   term.setTextColor(colors.white)
  71.   term.setCursorPos(1,2)
  72.   print(" Exit     ")
  73.   print(" Help     ")
  74.   print(" Info     ")
  75. end
  76.  
  77. function drawDialog()
  78.   term.setBackgroundColor(colors.white)
  79.   clear()
  80.   drawIcons()
  81.   drawTitle()
  82. end
  83.  
  84. function closeDialog()
  85.   red_active = false
  86.   shell.run("start")
  87. end
  88.  
  89. function showHelp()
  90.   clear()
  91.   drawTitle()
  92.   print("Select a color to blablabal")
  93.   print("Blablabbalballbalblablal")
  94.   print("Diverse.informationen")
  95. end
  96.  
  97. function showInfo()
  98.  
  99. end
  100.  
  101. drawDialog()
  102. sleep(0.5)
  103. while red_active do
  104.   local event, button, x, y = os.pullEventRaw()
  105.   if slc==0 then
  106.     if event=="mouse_click" then
  107.       if x>=2 and x<=7 and y==1 and button==1 then
  108.         --Startmenu
  109.         slc = 1
  110.         showStartMenu()
  111.         break
  112.       elseif x==51 and y==1 and button==1 then
  113.         --Close (X)
  114.         closeDialog()
  115.       end
  116.      
  117.       --NOW THE COLOR ICONS
  118.       for i=0,1 do
  119.         for j=0,7 do
  120.           if x>=(j*6+2) and x<=(j*6+8) and y>=(i*4+3) and y<=(i*4+6) and button==1 then
  121.             term.setCursorPos((j*6+3),(i*4+4))
  122.             if outputs[i*8+(j+1)]=="On" then
  123.               outputs[i*8+(j+1)] = "Off"
  124.             else
  125.               outputs[i*8+(j+1)] = "On"
  126.             end
  127.             drawIcons()
  128.             --
  129.             term.setCursorPos((j*6+3),(i*4+4))
  130.             print(i*8+(j+1))
  131.             --
  132.           else
  133.             drawDialog()
  134.           end
  135.         end
  136.       end
  137.     end
  138.   elseif slc==1 then
  139.     if event=="mouse_click" then
  140.       if x<=10 and button==1 then
  141.         if y==2 then
  142.           --Exit
  143.           closeDialog()
  144.         elseif y==3 then
  145.           --Help
  146.           slc = 2
  147.           showHelp()
  148.         elseif y==4 then
  149.           --Info
  150.           showInfo()
  151.         else
  152.           slc = 0
  153.           drawDialog()
  154.         end
  155.       else
  156.         slc = 0
  157.         drawDialog()
  158.       end
  159.     end
  160.   elseif slc==2 then
  161.     if event=="mouse_click" then
  162.       if x==51 and y==1 and button==1 then
  163.         slc = 0
  164.         drawDialog()
  165.       end
  166.     end
  167.   end  
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement