Advertisement
HyperQ

Slot Machine - Tekkit

Jun 18th, 2012
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.69 KB | None | 0 0
  1. -- Change camount to set how many prizes to give out.
  2. -- if you are using this on a multiplayer server
  3. -- add a way to stop them being able to access the terminal(add a script to make un-terminatable)
  4. camount = 10
  5. shell.run("clear",1)
  6. mon = peripheral.wrap("right")
  7. mon.clear()
  8. mon.setCursorPos(1,1)
  9. mon.write(" Press")
  10. mon.setCursorPos(1,2)
  11. mon.write(" Button")
  12. mon.setCursorPos(1,3)
  13. mon.write("To Play")
  14. mon.setCursorPos(1,4)
  15. mon.write(" Slots")
  16. print("Welcome, Hold Control + T to edit code")
  17.  
  18. function winner()
  19.     sleep(2)
  20.     mon = peripheral.wrap("right")
  21.     mon.clear()
  22.     mon.setCursorPos(1,1)
  23.     mon.write("*-*-*-*")
  24.     mon.setCursorPos(1,2)
  25.     mon.write("-*-*-*-")
  26.     mon.setCursorPos(1,3)
  27.     mon.write("Winner!")
  28.     mon.setCursorPos(1,4)
  29.     mon.write("-*-*-*-")
  30.     mon.setCursorPos(1,5)
  31.     mon.write("*-*-*-*")
  32.     sleep(0.5)
  33.     mon.clear()
  34.     mon.setCursorPos(1,1)
  35.     mon.write("-*-*-*-")
  36.     mon.setCursorPos(1,2)
  37.     mon.write("*-*-*-*")
  38.     mon.setCursorPos(1,3)
  39.     mon.write("Winner!")
  40.     mon.setCursorPos(1,4)
  41.     mon.write("*-*-*-*")
  42.     mon.setCursorPos(1,5)
  43.     mon.write("-*-*-*-")
  44.     sleep(0.5)
  45.     mon.clear()
  46.     mon.setCursorPos(1,1)
  47.     mon.write("*-*-*-*")
  48.     mon.setCursorPos(1,2)
  49.     mon.write("-*-*-*-")
  50.     mon.setCursorPos(1,3)
  51.     mon.write("Winner!")
  52.     mon.setCursorPos(1,4)
  53.     mon.write("-*-*-*-")
  54.     mon.setCursorPos(1,5)
  55.     mon.write("*-*-*-*")
  56.     sleep(0.5)
  57.     mon.clear()
  58.     mon.setCursorPos(1,1)
  59.     mon.write("-*-*-*-")
  60.     mon.setCursorPos(1,2)
  61.     mon.write("*-*-*-*")
  62.     mon.setCursorPos(1,3)
  63.     mon.write("Winner!")
  64.     mon.setCursorPos(1,4)
  65.     mon.write("*-*-*-*")
  66.     mon.setCursorPos(1,5)
  67.     mon.write("-*-*-*-")
  68.     sleep(0.5)
  69.     mon.clear()
  70.     mon.setCursorPos(1,1)
  71.     mon.write("*-*-*-*")
  72.     mon.setCursorPos(1,2)
  73.     mon.write("-*-*-*-")
  74.     mon.setCursorPos(1,3)
  75.     mon.write("Winner!")
  76.     mon.setCursorPos(1,4)
  77.     mon.write("-*-*-*-")
  78.     mon.setCursorPos(1,5)
  79.     mon.write("*-*-*-*")
  80.     sleep(0.5)
  81.     mon.clear()
  82.     mon.setCursorPos(1,1)
  83.     mon.write("-*-*-*-")
  84.     mon.setCursorPos(1,2)
  85.     mon.write("*-*-*-*")
  86.     mon.setCursorPos(1,3)
  87.     mon.write("Winner!")
  88.     mon.setCursorPos(1,4)
  89.     mon.write("*-*-*-*")
  90.     mon.setCursorPos(1,5)
  91.     mon.write("-*-*-*-")
  92. end
  93.  
  94. function Loser()
  95.     sleep(2)
  96.     mon = peripheral.wrap("right")
  97.     mon.clear()
  98.     mon.setCursorPos(1,1)
  99.     mon.write("*-*-*-*")
  100.     mon.setCursorPos(1,2)
  101.     mon.write("-*-*-*-")
  102.     mon.setCursorPos(1,3)
  103.     mon.write("Loser!!")
  104.     mon.setCursorPos(1,4)
  105.     mon.write("-*-*-*-")
  106.     mon.setCursorPos(1,5)
  107.     mon.write("*-*-*-*")
  108.     sleep(0.5)
  109.     mon.clear()
  110.     mon.setCursorPos(1,1)
  111.     mon.write("-*-*-*-")
  112.     mon.setCursorPos(1,2)
  113.     mon.write("*-*-*-*")
  114.     mon.setCursorPos(1,3)
  115.     mon.write("Loser!!")
  116.     mon.setCursorPos(1,4)
  117.     mon.write("*-*-*-*")
  118.     mon.setCursorPos(1,5)
  119.     mon.write("-*-*-*-")
  120.     sleep(0.5)
  121.     mon.clear()
  122.     mon.setCursorPos(1,1)
  123.     mon.write("*-*-*-*")
  124.     mon.setCursorPos(1,2)
  125.     mon.write("-*-*-*-")
  126.     mon.setCursorPos(1,3)
  127.     mon.write("Loser!!")
  128.     mon.setCursorPos(1,4)
  129.     mon.write("-*-*-*-")
  130.     mon.setCursorPos(1,5)
  131.     mon.write("*-*-*-*")
  132.     sleep(0.5)
  133.     mon.clear()
  134.     mon.setCursorPos(1,1)
  135.     mon.write("-*-*-*-")
  136.     mon.setCursorPos(1,2)
  137.     mon.write("*-*-*-*")
  138.     mon.setCursorPos(1,3)
  139.     mon.write("Loser!!")
  140.     mon.setCursorPos(1,4)
  141.     mon.write("*-*-*-*")
  142.     mon.setCursorPos(1,5)
  143.     mon.write("-*-*-*-")
  144.     sleep(0.5)
  145.     mon.clear()
  146.     mon.setCursorPos(1,1)
  147.     mon.write("*-*-*-*")
  148.     mon.setCursorPos(1,2)
  149.     mon.write("-*-*-*-")
  150.     mon.setCursorPos(1,3)
  151.     mon.write("Loser!!")
  152.     mon.setCursorPos(1,4)
  153.     mon.write("-*-*-*-")
  154.     mon.setCursorPos(1,5)
  155.     mon.write("*-*-*-*")
  156.     sleep(0.5)
  157.     mon.clear()
  158.     mon.setCursorPos(1,1)
  159.     mon.write("-*-*-*-")
  160.     mon.setCursorPos(1,2)
  161.     mon.write("*-*-*-*")
  162.     mon.setCursorPos(1,3)
  163.     mon.write("Loser!!")
  164.     mon.setCursorPos(1,4)
  165.     mon.write("*-*-*-*")
  166.     mon.setCursorPos(1,5)
  167.     mon.write("-*-*-*-")
  168. end
  169.  
  170. function slots()
  171.     result1 = math.random(1,7)
  172.     result1 = result1 - ".0"
  173.  
  174.     result2 = math.random(1,7)
  175.     result2 = result2 - ".0"
  176.  
  177.     result3 = math.random(1,7)
  178.     result3 = result3 - ".0"
  179.  
  180.     result4 = math.random(1,7)
  181.     result4 = result4 - ".0"
  182.  
  183.     result5 = math.random(1,7)
  184.     result5 = result5 - ".0"
  185.  
  186.     result6 = math.random(1,7)
  187.     result6 = result6 - ".0"
  188.  
  189.     result7 = math.random(1,7)
  190.     result7 = result7 - ".0"
  191.  
  192.     result8 = math.random(1,7)
  193.     result8 = result8 - ".0"
  194.  
  195.     result9 = math.random(1,7)
  196.     result9 = result9 - ".0"
  197.  
  198.     term.setCursorPos(25,5)
  199.     mon = peripheral.wrap("right")
  200.     mon.clear()
  201.     mon.setCursorPos(1,1)
  202.     mon.write("*******")
  203.     mon.setCursorPos(2,2)
  204.     mon.write(result1.."|"..result2.."|"..result3)
  205.     mon.setCursorPos(2,3)
  206.     mon.write(result4.."|"..result5.."|"..result6)
  207.     mon.setCursorPos(2,4)
  208.     mon.write(result7.."|"..result8.."|"..result9)
  209.     mon.setCursorPos(1,5)
  210.     mon.write("*******")
  211.     term.setCursorPos(1,3)
  212.     print("Debug Info:")
  213.     print("Results:   "..result1.."|"..result2.."|"..result3)
  214.     print("           "..result4.."|"..result5.."|"..result6)
  215.     print("           "..result7.."|"..result8.."|"..result9)
  216.  
  217.     if result1 == result2 and result2 == result3 then
  218.         print("Row Match, Top Row")
  219.         winner()
  220.         cpayout = 0
  221.         while cpayout < camount do
  222.             redstone.setOutput("bottom",true)
  223.             sleep(0.2)
  224.             redstone.setOutput("bottom",false)
  225.             sleep(0.2)
  226.             cpayout = cpayout +1
  227.         end
  228.         os.reboot()
  229.     elseif result4 == result5 and result5 == result6 then
  230.         print("Row Match, Middle Row")
  231.         winner()
  232.         cpayout = 0
  233.         while cpayout < camount do
  234.             redstone.setOutput("bottom",true)
  235.             sleep(0.2)
  236.             redstone.setOutput("bottom",false)
  237.             sleep(0.2)
  238.             cpayout = cpayout +1
  239.         end
  240.         os.reboot()
  241.     elseif result7 == result8 and result8 == result9 then
  242.         print("Row Match, Bottom Row")
  243.         winner()
  244.         cpayout = 0
  245.         while cpayout < camount do
  246.             redstone.setOutput("bottom",true)
  247.             sleep(0.2)
  248.             redstone.setOutput("bottom",false)
  249.             sleep(0.2)
  250.             cpayout = cpayout +1
  251.         end
  252.         os.reboot()
  253.     elseif result1 == result5 and result5 == result9 then
  254.         print("Diagonal Match From top to bottom.")
  255.         winner()
  256.         cpayout = 0
  257.         while cpayout < camount do
  258.             redstone.setOutput("bottom",true)
  259.             sleep(0.2)
  260.             redstone.setOutput("bottom",false)
  261.             sleep(0.2)
  262.             cpayout = cpayout +1
  263.         end
  264.         os.reboot()
  265.     elseif result7 == result5 and result5 == result3 then
  266.         print("Diagonal Match From bottom to top.")
  267.         winner()
  268.         cpayout = 0
  269.         while cpayout < camount do
  270.             redstone.setOutput("bottom",true)
  271.             sleep(0.2)
  272.             redstone.setOutput("bottom",false)
  273.             sleep(0.2)
  274.             cpayout = cpayout +1
  275.         end
  276.         os.reboot()
  277.     else
  278.         print("There was No Match")
  279.         Loser()
  280.         sleep(2)
  281.         os.reboot()
  282.     end
  283.  
  284. end
  285.  
  286. local rRunning = true
  287.  
  288. while rRunning do
  289.   sleep(0.5)
  290.   local rEvent, param = os.pullEvent()
  291.   if rEvent == "redstone" then
  292.     if redstone.getInput("back") then
  293.       if redstone.getInput("back") == true then
  294.       slots()
  295.       else
  296.         shell.run("clear",1)
  297.       end
  298.     end
  299.   end
  300. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement