Advertisement
NeonJ

DDR Game

Jul 4th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.69 KB | None | 0 0
  1. -- DDRGame
  2.  
  3. local rRunning = 1
  4. a1 = 0
  5. a2 = 0
  6. a3 = 0
  7. a4 = 0
  8. a5 = 0
  9. a6 = 0
  10. b1 = 0
  11. b2 = 0
  12. b3 = 0
  13. b4 = 0
  14. b5 = 0
  15. b6 = 0
  16. c1 = 0
  17. c2 = 0
  18. c3 = 0
  19. c4 = 0
  20. c5 = 0
  21. c6 = 0
  22. d1 = 0
  23. d2 = 0
  24. d3 = 0
  25. d4 = 0
  26. d5 = 0
  27. d6 = 0
  28. aHold = 0
  29. bHold = 0
  30. cHold = 0
  31. dHold = 0
  32. Score = 0
  33. Life = 16
  34. GameOn = 0
  35.  
  36. -- a = Green, b = Blue, c = Red, d = Yellow
  37.  
  38. while rRunning == 1 do
  39.  if GameOn == 0 then
  40.   print("Debug: Awaiting Redstone Input!")
  41.   local rEvent, param = os.pullEvent()
  42.   if rEvent == "redstone" then
  43.    if redstone.getInput("back") then
  44.      if redstone.getInput("back") == true then
  45.      print("Debug: Input!")
  46.      GameOn = 1
  47.      end
  48.     end
  49.   end
  50.  else
  51.      if colors.test(redstone.getBundledInput("top"), colors.green) == true then aHold = 1
  52.      else aHold = 0 end
  53.      if colors.test(redstone.getBundledInput("top"), colors.blue) == true then bHold = 1
  54.      else bHold = 0 end
  55.      if colors.test(redstone.getBundledInput("top"), colors.red) == true then cHold = 1
  56.      else cHold = 0 end
  57.      if colors.test(redstone.getBundledInput("top"), colors.yellow) == true then dHold = 1
  58.      else dHold = 0 end
  59.      
  60.      if aHold == 1 and a1 == 1 then
  61.       Score = Score + 1
  62.      elseif aHold == 0 and a1 == 1 then
  63.       Life = Life - 1
  64.      end
  65.      if bHold == 1 and b1 == 1 then
  66.       Score = Score + 1
  67.      elseif bHold == 0 and b1 == 1 then
  68.       Life = Life - 1
  69.      end
  70.      if cHold == 1 and c1 == 1 then
  71.       Score = Score + 1
  72.      elseif cHold == 0 and c1 == 1 then
  73.       Life = Life - 1
  74.      end
  75.      if dHold == 1 and d1 == 1 then
  76.       Score = Score + 1
  77.      elseif dHold == 0 and d1 == 1 then
  78.       Life = Life - 1
  79.      end
  80.      
  81.      a1 = a2
  82.      a2 = a3
  83.      a3 = a4
  84.      a4 = a5
  85.      a5 = a6
  86.      b1 = b2
  87.      b2 = b3
  88.      b3 = b4
  89.      b4 = b5
  90.      b5 = b6
  91.      c1 = c2
  92.      c2 = c3
  93.      c3 = c4
  94.      c4 = c5
  95.      c5 = c6
  96.      d1 = d2
  97.      d2 = d3
  98.      d3 = d4
  99.      d4 = d5
  100.      d5 = d6
  101.      
  102.      result1 = math.random(1,4)
  103.      result1 = result1 - ".0"
  104.      if result1 == 1 then
  105.       a6 = 1
  106.       b6 = 0
  107.       c6 = 0
  108.       d6 = 0
  109.       print("Debug: A is going!")
  110.      elseif result1 == 2 then
  111.       b6 = 1
  112.       a6 = 0
  113.       c6 = 0
  114.       d6 = 0
  115.       print("Debug: B is going!")
  116.      elseif result1 == 3 then
  117.       c6 = 1
  118.       a6 = 0
  119.       b6 = 0
  120.       d6 = 0
  121.       print("Debug: C is going!")
  122.      elseif result1 == 4 then
  123.       d6 = 1
  124.       a6 = 0
  125.       b6 = 0
  126.       c6 = 0
  127.       print("Debug: D is going!")
  128.      end
  129.      
  130.      leftredstone = 0
  131.      rightredstone = 0
  132.      
  133.      if a1 == 1 then leftredstone = leftredstone + 1 end
  134.      if a2 == 1 then leftredstone = leftredstone + 2 end
  135.      if a3 == 1 then leftredstone = leftredstone + 4 end
  136.      if a4 == 1 then leftredstone = leftredstone + 8 end
  137.      if a5 == 1 then leftredstone = leftredstone + 16 end
  138.      if a6 == 1 then leftredstone = leftredstone + 32 end
  139.      if b1 == 1 then leftredstone = leftredstone + 64 end
  140.      if b2 == 1 then leftredstone = leftredstone + 128 end
  141.      if b3 == 1 then leftredstone = leftredstone + 256 end
  142.      if b4 == 1 then leftredstone = leftredstone + 512 end
  143.      if b5 == 1 then leftredstone = leftredstone + 1024 end
  144.      if b6 == 1 then leftredstone = leftredstone + 2048 end
  145.      if c1 == 1 then rightredstone = rightredstone + 1 end
  146.      if c2 == 1 then rightredstone = rightredstone + 2 end
  147.      if c3 == 1 then rightredstone = rightredstone + 4 end
  148.      if c4 == 1 then rightredstone = rightredstone + 8 end
  149.      if c5 == 1 then rightredstone = rightredstone + 16 end
  150.      if c6 == 1 then rightredstone = rightredstone + 32 end
  151.      if d1 == 1 then rightredstone = rightredstone + 64 end
  152.      if d2 == 1 then rightredstone = rightredstone + 128 end
  153.      if d3 == 1 then rightredstone = rightredstone + 256 end
  154.      if d4 == 1 then rightredstone = rightredstone + 512 end
  155.      if d5 == 1 then rightredstone = rightredstone + 1024 end
  156.      if d6 == 1 then rightredstone = rightredstone + 2048 end
  157.      
  158.      print("Debug: Life: "..Life)
  159.      print("Debug: Score: "..Score)
  160.      if Life == 0 then
  161.       print("Debug: Game Over!")
  162.       GameOn = 0
  163.       a1 = 0
  164.       a2 = 0
  165.       a3 = 0
  166.       a4 = 0
  167.       a5 = 0
  168.       a6 = 0
  169.       b1 = 0
  170.       b2 = 0
  171.       b3 = 0
  172.       b4 = 0
  173.       b5 = 0
  174.       b6 = 0
  175.       c1 = 0
  176.       c2 = 0
  177.       c3 = 0
  178.       c4 = 0
  179.       c5 = 0
  180.       c6 = 0
  181.       d1 = 0
  182.       d2 = 0
  183.       d3 = 0
  184.       d4 = 0
  185.       d5 = 0
  186.       d6 = 0
  187.       Score = 0
  188.       Life = 16
  189.       rs.setBundledOutput("left",0)
  190.       rs.setBundledOutput("right",0)
  191.      else
  192.       rs.setBundledOutput("left",leftredstone)
  193.       rs.setBundledOutput("right",rightredstone)
  194.      end
  195.  sleep(1.2)
  196.  end
  197.  end
  198.  
  199. -- Yay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement