Advertisement
lego11

SLOTMACHINE CARTA

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