Advertisement
SirMongoose

Redpwr

Aug 5th, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.39 KB | None | 0 0
  1. --Redpwr - v1.0.0 - Created by Sir.Mongoose!
  2.  
  3. local s1 = 1 local s1p = 0 --x;11 y;8  
  4. local s2 = 2 local s2p = 0 --x;11 y;10
  5. local s3 = 3 local s3p = 0 --x;11 y;12
  6. local s4 = 4 local s4p = 0 --x;33 y;8
  7. local s5 = 5 local s5p = 0 --x;33 y;10
  8. local s6 = 6 local s6p = 0 --x;33 y;12
  9. local x = 14 local y = 8
  10. local cur = 1
  11.  
  12. function draw(p,x,y)
  13.     if p == 0 then
  14.         term.setCursorPos(x,y)
  15.         write("OFF")
  16.     elseif p > 0 then
  17.         term.setCursorPos(x,y)
  18.         write(" "..p)
  19.     end
  20. end
  21.  
  22. function signalP()
  23.     if cur == 1 then
  24.         x = 14
  25.         y = 8
  26.     elseif cur == 2 then
  27.         x = 14
  28.         y = 10
  29.     elseif cur == 3 then
  30.         x = 14
  31.         y = 12
  32.     elseif cur == 4 then
  33.         x = 36
  34.         y = 8
  35.     elseif cur == 5 then
  36.         x = 36
  37.         y = 10
  38.     elseif cur == 6 then
  39.         x = 36
  40.         y = 12
  41.     end
  42.     draw(s1p,10,8)
  43.     draw(s2p,10,10)
  44.     draw(s3p,10,12)
  45.     draw(s4p,32,8)
  46.     draw(s5p,32,10)
  47.     draw(s6p,32,12)
  48. end
  49.  
  50. function power()
  51.     redstone.setAnalogOutput("front",s1p)
  52.     redstone.setAnalogOutput("back",s2p)
  53.     redstone.setAnalogOutput("left",s3p)
  54.     redstone.setAnalogOutput("right",s4p)
  55.     redstone.setAnalogOutput("top",s5p)
  56.     redstone.setAnalogOutput("bottom",s6p) 
  57. end
  58.  
  59. function display()
  60.     term.clear()
  61.     term.setCursorPos(1,1)
  62.         print("REDPWR v1.0.0")
  63.         print("")
  64.         print("CREATED BY SIR.MONGOOSE")
  65.     term.setCursorPos(1,6)     
  66.         print("SIDES | SIGNAL        SIDES | SIGNAL")
  67.         print("==============        ==============")
  68.         print("FRONT |   *           RIGHT |   *   ")
  69.         print("--------------        --------------")
  70.         print("BACK  |   *           TOP   |   *   ")
  71.         print("--------------        --------------")
  72.         print("LEFT  |   *           BOTTOM|   *   ")
  73.         print("--------------        --------------")
  74.     term.setCursorPos(1,16)
  75.         print(" [PRESS BACKSPACE TO EXIT PROGRAM]  ")
  76.         print("   [USE ARROW KEYS TO NAVIGATE]")
  77.     signalP()
  78.     term.setCursorPos(x,y)
  79.     write("*")
  80. end
  81.  
  82. while true do
  83.     display()
  84.     power()
  85.         local event, key = os.pullEvent()
  86.     if key == keys.backspace then
  87.         break
  88.     elseif key == keys.right then
  89.         if cur > 6 then
  90.             cur = cur - 1
  91.         else
  92.             cur = cur + 1
  93.         end
  94.         if cur == 7 then
  95.             cur = 6
  96.         end
  97.     elseif key == keys.left then
  98.         if cur < 1 then
  99.             cur = cur + 1
  100.         else
  101.             cur = cur - 1
  102.         end
  103.         if cur == 0 then
  104.             cur = 1
  105.         end
  106.     elseif key == keys.up then
  107.         if cur == 1 then
  108.             if s1p ~= 15 then
  109.                 s1p = s1p + 1
  110.             end
  111.         elseif cur == 2 then
  112.             if s2p ~= 15 then
  113.                 s2p = s2p + 1
  114.             end
  115.         elseif cur == 3 then
  116.             if s3p ~= 15 then
  117.                 s3p = s3p + 1
  118.             end
  119.         elseif cur == 4 then
  120.             if s4p ~= 15 then
  121.                 s4p = s4p + 1
  122.             end
  123.         elseif cur == 5 then
  124.             if s5p ~= 15 then
  125.                 s5p = s5p + 1
  126.             end
  127.         elseif cur == 6 then
  128.             if s6p ~= 15 then
  129.                 s6p = s6p + 1
  130.             end
  131.         end
  132.     elseif key == keys.down then
  133.         if cur == 1 then
  134.             if s1p ~= 0 then
  135.                 s1p = s1p - 1
  136.             end
  137.         elseif cur == 2 then
  138.             if s2p ~= 0 then
  139.                 s2p = s2p - 1
  140.             end
  141.         elseif cur == 3 then
  142.             if s3p ~= 0 then
  143.                 s3p = s3p - 1
  144.             end
  145.         elseif cur == 4 then
  146.             if s4p ~= 0 then
  147.                 s4p = s4p - 1
  148.             end
  149.         elseif cur == 5 then
  150.             if s5p ~= 0 then
  151.                 s5p = s5p - 1
  152.             end
  153.         elseif cur == 6 then
  154.             if s6p ~= 0 then
  155.                 s6p = s6p - 1
  156.             end
  157.         end
  158.     end
  159. end
  160.  
  161. term.setCursorPos(1,1)
  162. term.clear()
  163. redstone.setAnalogOutput("front",0)
  164. redstone.setAnalogOutput("back",0)
  165. redstone.setAnalogOutput("left",0)
  166. redstone.setAnalogOutput("right",0)
  167. redstone.setAnalogOutput("top",0)
  168. redstone.setAnalogOutput("bottom",0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement