Advertisement
Vilsol

PaintballServer

Feb 24th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.61 KB | None | 0 0
  1. tArgs = { ... }
  2.  
  3. term.clear()
  4. term.setCursorPos(1,1)
  5.  
  6. back = 0
  7. left = 0
  8. right = 0
  9. front = 0
  10. top = 0
  11. bottom = 0
  12.  
  13. backc = 0
  14. leftc = 0
  15. rightc = 0
  16. frontc = 0
  17. topc = 0
  18. botc = 0
  19.  
  20. last = ""
  21. locked = 0
  22. free = 0
  23.  
  24. colseq = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red}
  25.  
  26. if(tArgs[1] == "update")then
  27.     shell.run("rm", "PB")
  28.     shell.run("pastebin", "get", "AFiiZJ5B", "PB")
  29.     print "Update successfull!"
  30.     error()
  31. end
  32.  
  33. function addPoint(color)
  34.     if(color == "red")then
  35.         if(frontc < 15)then
  36.             frontc = frontc + 1
  37.             front = 0
  38.             for addp = 1, frontc do
  39.                 front = front + colseq[addp]
  40.             end
  41.         end
  42.         redstone.setBundledOutput("front", front)
  43.     elseif(color == "blue")then
  44.         if(backc < 15)then
  45.             backc = backc + 1
  46.             back = 0
  47.             for addp = 1, backc do
  48.                 back = back + colseq[addp]
  49.             end
  50.         end
  51.         redstone.setBundledOutput("back", back)
  52.     elseif(color == "green")then
  53.         if(rightc < 15)then
  54.             rightc = rightc + 1
  55.             right = 0
  56.             for addp = 1, rightc do
  57.                 right = right + colseq[addp]
  58.             end
  59.         end
  60.         redstone.setBundledOutput("right", right)
  61.     elseif(color == "yellow")then
  62.         if(leftc < 15)then
  63.             leftc = leftc + 1
  64.             left = 0
  65.             for addp = 1, leftc do
  66.                 left = left + colseq[addp]
  67.             end
  68.         end
  69.         redstone.setBundledOutput("left", left)
  70.     elseif(color == "purple")then
  71.         if(bottomc < 15)then
  72.             bottomc = bottomc + 1
  73.             bottom = 0
  74.             for addp = 1, bottomc do
  75.                 bottom = bottom + colseq[addp]
  76.             end
  77.         end
  78.         redstone.setBundledOutput("bottom", bottom)
  79.     elseif(color == "orange")then
  80.         if(topc < 15)then
  81.             topc = topc + 1
  82.             top = 0
  83.             for addp = 1, topc do
  84.                 top = top + colseq[addp]
  85.             end
  86.         end
  87.         redstone.setBundledOutput("top", top)
  88.     end
  89. end
  90.  
  91. while true do
  92.     free = 0
  93.     if(locked == 0)then
  94.         os.pullEvent("redstone")
  95.     end
  96.     fronts = redstone.testBundledInput("front", colors.black)
  97.     backs = redstone.testBundledInput("back", colors.black)
  98.     lefts = redstone.testBundledInput("left", colors.black)
  99.     rights = redstone.testBundledInput("right", colors.black)
  100.     tops = redstone.testBundledInput("top", colors.black)
  101.     bottoms = redstone.testBundledInput("bottom", colors.black)
  102.     if(locked == 0 or last == "red")then
  103.         if(fronts)then
  104.             if(last == "red")then
  105.                 addPoint("red")
  106.             end
  107.             locked = 1
  108.             last = "red"
  109.         else
  110.             locked = 0
  111.             last = ""
  112.         end
  113.     end
  114.     if(locked == 0 or last == "blue")then
  115.         if(backs)then
  116.             if(last == "blue")then
  117.                 addPoint("blue")
  118.             end
  119.             locked = 1
  120.             last = "blue"
  121.         else
  122.             locked = 0
  123.             last = ""
  124.         end
  125.     end
  126.     if(locked == 0 or last == "green")then
  127.         if(rights)then
  128.             if(last == "green")then
  129.                 addPoint("green")
  130.             end
  131.             locked = 1
  132.             last = "green"
  133.         else
  134.             locked = 0
  135.             last = ""
  136.         end
  137.     end
  138.     if(locked == 0 or last == "yellow")then
  139.         if(lefts)then
  140.             if(last == "yellow")then
  141.                 addPoint("yellow")
  142.             end
  143.             locked = 1
  144.             last = "yellow"
  145.         else
  146.             locked = 0
  147.             last = ""
  148.         end
  149.     end
  150.     if(locked == 0 or last == "purple")then
  151.         if(bottoms)then
  152.             if(last == "purple")then
  153.                 addPoint("purple")
  154.             end
  155.             locked = 1
  156.             last = "purple"
  157.         else
  158.             locked = 0
  159.             last = ""
  160.         end
  161.     end
  162.     if(locked == 0 or last == "orange")then
  163.         if(tops)then
  164.             if(last == "orange")then
  165.                 addPoint("orange")
  166.             end
  167.             locked = 1
  168.             last = "orange"
  169.         else
  170.             locked = 0
  171.             last = ""
  172.         end
  173.     end
  174.     if(not tops and not bottoms and not lefts and not rights and not fronts and not backs)then
  175.         locked = 0
  176.         last = ""
  177.     end
  178.     print (last)
  179.     sleep(5)
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement