Advertisement
Rolcam

Computercraft Roulette [WIP]

Oct 23rd, 2021 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.79 KB | None | 0 0
  1. -- Debug Mode Toggle 1/0
  2. debug = 0
  3. -- Y variable override - only works when in debug mode
  4. dY = 0
  5. -- Credit Variable - Leave it at 0 unless you are debugging or want to give out free plays for a while
  6. credits = 0
  7. -- Credits needed to complete the bet, used when the purchase credits screen pops up
  8. neededCred = 0
  9. -- Credit Screen Lock - triggers if not enough credits to cover the bet(s) were purchased
  10. credLock = 0
  11. -- Check for credit system, leave this alone
  12. check = 0
  13. -- Bet Variables
  14. -- Bet on red
  15. redBet = 0
  16. -- Bet on black
  17. blackBet = 0
  18. -- Bet on even
  19. evenBet = 0
  20. -- Bet on odd
  21. oddBet = 0
  22. -- Bet on 1st 12s
  23. bet112 = 0
  24. -- Bet on 2nd 12s
  25. bet212 = 0
  26. -- Bet on 3rd 12s
  27. bet312 = 0
  28. -- Total bet balance
  29. tBet = 0
  30. mon = peripheral.wrap("right")
  31. -- Scale 2: 14 Chars - Scale 3: 10 Chars
  32. mon.setTextScale(2)
  33. while true do  
  34.     -- Payment System disabled during testing phase
  35.    
  36.     -- Light Gray - End Cashout
  37.     -- Magenta - Payment Screen Probe (from payment kiosk) - Input
  38.     -- White - Payment Screen Confirmation - Output
  39. --[[
  40.         payScreen = function()
  41.         -- Checks for credits
  42.         term.redirect(mon)
  43.         if credits == 0 then
  44.             while check == 0 do
  45.                 term.setBackgroundColor(colors.green)
  46.                 term.clear()
  47.                 term.setCursorPos(10,8)
  48.                 print("Please Purchase Credits")
  49.                 term.setCursorPos(10,9)
  50.                 print("Press the button when finished")
  51.                 term.setCursorPos(10,10)
  52.                 print("Credits Purchased: "..credits.." credits")
  53.                 if neededCred == 0 then
  54.                     sleep(0.1)
  55.                     credLock = 0
  56.                 elseif neededCred < credits then
  57.                     print("Credits Needed: " .. neededCred .. " credits")
  58.                     print("Sufficient Credits purchased")
  59.                     credLock = 0
  60.                 else
  61.                     print("Credits Needed: " .. neededCred .. " credits")
  62.                     print("Insufficient Credits to cover your bet(s)")
  63.                     print("Please purchase more credits")
  64.                     credLock = 1
  65.                 end
  66.                 local event = os.pullEvent("redstone")
  67.                 if rs.testBundledInput("back", colors.purple) == true then
  68.                     check = 1
  69.                 end
  70.                 if rs.testBundledInput("back", colors.lime) == true then
  71.                     credits = credits + 1
  72.                 elseif rs.testBundledInput("back", colors.green) == true then
  73.                     credits = credits + 5
  74.                 elseif rs.testBundledInput("back", colors.gray) == true then
  75.                     credits = credits + 10
  76.                 elseif rs.testBundledInput("back", colors.blue) == true then
  77.                     credits = credits + 50
  78.                 elseif rs.testBundledInput("back", colors.orange) == true then
  79.                     credits = credits + 100
  80.                 elseif rs.testBundledInput("back", colors.brown) == true then
  81.                     credits = credits + 500
  82.                 elseif rs.testBundledInput("back", colors.red) == true then
  83.                     credits = credits + 1000
  84.                 elseif rs.testBundledInput("back", colors.cyan) == true then
  85.                     credits = credits + 5000
  86.                 elseif rs.testBundledInput("back", colors.pink) == true then
  87.                     credits = credits + 10000
  88.                 end
  89.                
  90.             sleep(0.1)
  91.             end
  92.         end
  93.         if credits == 0 then
  94.             print("No credits purchased! Rebooting...")
  95.             sleep(3)
  96.             os.reboot()
  97.         end
  98.     term.restore()
  99. end
  100. payScreen(0)
  101. ]]--
  102.     -- Wheel Data, this is so the wheel looks like the real deal in terms of number placement
  103.     wheelDat = { 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26}
  104.     -- Timer Variable
  105.     x = 0.1
  106.     -- Roulette Numbers
  107.     y = 1
  108.     y1 = 0
  109.     y2 = 0
  110.     y3 = 0
  111.     y4 = 0
  112.     -- Timer Hold Variable
  113.     z = math.random(72,200)
  114.    
  115.     -- Bets Code
  116.     -- Generates table for bets on specific numbers
  117.     wipeBets = function()
  118.         numBets = 0
  119.         numBets = {}
  120.         for i = 0, 36 do
  121.             numBets[i] = "0"
  122.             if debug == 1 then
  123.                 print(numBets[i])
  124.             end
  125.         end
  126.         -- Bet on red  
  127.         redBet = 0
  128.         -- Bet on black
  129.         blackBet = 0
  130.         -- Bet on even
  131.         evenBet = 0
  132.         -- Bet on odd
  133.         oddBet = 0
  134.         -- Bet on 1st 12s
  135.         bet112 = 0
  136.         -- Bet on 2nd 12s
  137.         bet212 = 0
  138.         -- Bet on 3rd 12s
  139.         bet312 = 0
  140.         -- Total bet balance
  141.         tBet = 0
  142.         if debug == 1 then
  143.             print("Bet data wiped. Ready for new bets!")
  144.             sleep(2)
  145.         end
  146.     end
  147.    
  148.     -- "Wheel" Code
  149.     term.setBackgroundColor(colors.blue)
  150.     term.clear()
  151.     term.setCursorPos(1,1)
  152.     term.setTextColor(colors.white)
  153.     print("Roulette V1 - by Rolcam \n ")
  154.     print("Spinning the wheel...")
  155.     print("Check the monitor")
  156.     while x < 1.6 do
  157.         mon.setBackgroundColor(colors.blue)
  158.         mon.clear()
  159.         mon.setCursorPos(7,1)
  160.         -- V is the "Ball"/Pointer - Keep this on the middle number
  161.         -- ##X##X##X##X##
  162.         mon.write("V")
  163.         -- Assigns the value of y - the # the "ball" is currently on top of
  164.         if y < 37 then
  165.             y = y + 1
  166.         else
  167.             y = 1
  168.         end
  169.         -- Assigns the value of y1 - The # that goes before y2 - 2 before y
  170.         if y == 1 then
  171.             y1 = 36
  172.         elseif y == 2 then
  173.             y1 = 37
  174.         else
  175.             y1 = y - 2
  176.         end
  177.          -- Assigns the value of y2 - The # that goes before y1
  178.         if y == 1 then
  179.             y2 = 37
  180.         else
  181.             y2 = y - 1
  182.         end
  183.         -- Assigns the value of y3 - The # that goes after y
  184.         if y == 37 then
  185.             y3 = 1
  186.         else
  187.             y3 = y + 1
  188.         end
  189.         -- Assigns the value of y4 - The # that goes after y3 - 2 after y
  190.         if y == 37 then
  191.             y4 = 2
  192.         elseif y == 36 then
  193.             y4 = 1
  194.         else
  195.             y4 = y + 2
  196.         end
  197.         -- Prints the "Wheel"
  198.         if y1 == 1 then
  199.             mon.setBackgroundColor(colors.green)
  200.         elseif y1 % 2 == 0 then
  201.             mon.setBackgroundColor(colors.red)
  202.         else
  203.             mon.setBackgroundColor(colors.black)
  204.         end
  205.         mon.setCursorPos(1,2)
  206.         mon.write(tostring(wheelDat[y1]))
  207.        
  208.         if y2 == 1 then
  209.             mon.setBackgroundColor(colors.green)
  210.         elseif y2 % 2 == 0 then
  211.             mon.setBackgroundColor(colors.red)
  212.         else
  213.             mon.setBackgroundColor(colors.black)
  214.         end
  215.         mon.setCursorPos(4,2)
  216.         mon.write(tostring(wheelDat[y2]))
  217.        
  218.         if y == 1 then
  219.             mon.setBackgroundColor(colors.green)
  220.         elseif y % 2 == 0 then
  221.             mon.setBackgroundColor(colors.red)
  222.         else
  223.             mon.setBackgroundColor(colors.black)
  224.         end
  225.         mon.setCursorPos(7,2)
  226.         mon.write(tostring(wheelDat[y]))
  227.        
  228.         if y3 == 1 then
  229.             mon.setBackgroundColor(colors.green)
  230.         elseif y3 % 2 == 0 then
  231.             mon.setBackgroundColor(colors.red)
  232.         else
  233.             mon.setBackgroundColor(colors.black)
  234.         end
  235.         mon.setCursorPos(10,2)
  236.         mon.write(tostring(wheelDat[y3]))
  237.        
  238.         if y4 == 1 then
  239.             mon.setBackgroundColor(colors.green)
  240.         elseif y4 % 2 == 0 then
  241.             mon.setBackgroundColor(colors.red)
  242.         else
  243.             mon.setBackgroundColor(colors.black)
  244.         end
  245.         mon.setCursorPos(13,2)
  246.         mon.write(tostring(wheelDat[y4]))
  247.        
  248.         sleep(x)
  249.         if z > 0 then
  250.               z = z - 1
  251.         else
  252.             x = x + 0.1
  253.         end
  254.     end
  255.     mon.setBackgroundColor(colors.blue)
  256.     mon.setTextColor(colors.white)
  257.     mon.setCursorPos(1,4)
  258.     mon.write("Spin Complete")
  259.     mon.setCursorPos(1,5)
  260.     mon.write("Check Computer")
  261.     -- Display (Computer) Code
  262.     term.setBackgroundColor(colors.blue)
  263.     term.clear()
  264.     term.setCursorPos(1,1)
  265.     term.setTextColor(colors.white)
  266.     print("Roulette V1 - by Rolcam \n ")
  267.     print("Ball landed on: ")
  268.     -- Checks if the number is even or odd
  269.     if y == 1 then
  270.         eoVar = "Zero"
  271.         rbVar = "Green"
  272.         term.setTextColor(colors.green)
  273.     elseif wheelDat[y] % 2 == 0 then
  274.         eoVar = "Even"
  275.         term.setTextColor(colors.red)
  276.     else
  277.         eoVar = "Odd"
  278.         term.setTextColor(colors.black)
  279.     end
  280.     if y == 1 then
  281.         eoVar = "Zero"
  282.         rbVar = "Green"
  283.         term.setTextColor(colors.green)
  284.     elseif wheelDat[y] % 2 == 0 then
  285.         rbVar = "Red"
  286.         term.setTextColor(colors.red)
  287.     else
  288.         rbVar = "Black"
  289.         term.setTextColor(colors.black)
  290.     end
  291.     -- Checks if the number is high or low
  292.     if y == 1 then
  293.         twlvVar = 0
  294.     elseif 1 < y and y < 14 then
  295.         twlvVar = 1
  296.     elseif 13 < y and y < 26 then
  297.         twlvVar = 2
  298.     else
  299.         twlvVar = 3
  300.     end
  301.     if y == 1 then
  302.         hlVar = "N/A"
  303.     elseif y > 19 then
  304.         hlVar = "High"
  305.     else
  306.         hlVar = "Low"
  307.     end
  308.     term.setCursorPos(17,3)
  309.     if y == 1 then
  310.         print(wheelDat[y] .. " Zero")
  311.     else
  312.         print(wheelDat[y] .. " " .. rbVar)
  313.     end
  314.     if y == 1 then
  315.         term.setTextColor(colors.white)
  316.         print(" \n Payouts:")
  317.         print("Bet on 0: 36x")
  318.         print("Bet on Even: 0.5x - La Partage")
  319.         print("All else: No win")
  320.     else
  321.         term.setTextColor(colors.white)
  322.         print(" \nPayout Rates:")
  323.         print("Bet on " .. wheelDat[y] .. ": 36x")
  324.         if eoVar == "Odd" then
  325.             print("Bet on Odd: 2x")
  326.         else
  327.             print("Bet on Even: 2x")
  328.         end
  329.         if rbVar == "Black" then
  330.             print("Bet on Black: 2x")
  331.         else
  332.             print("Bet on White: 2x")
  333.         end
  334.         if hlVar == "High" then
  335.             print("Bet on High: 2x")
  336.         else
  337.             print("Bet on Low: 2x")
  338.         end
  339.         if twlvVar == 1 then
  340.             print("Bet on 1st 12s: 3x")
  341.         elseif twlvVar == 2 then
  342.             print("Bet on 2nd 12s: 3x")
  343.         else
  344.             print("Bet on 3rd 12s: 3x")
  345.         end
  346.         print("All else: No Win")
  347.     end
  348.     -- Bet Payment Code
  349.     --[[
  350.     winBal = 0
  351.     print("Your total winnings this round are: $"..winBal)
  352.    
  353.     ]]--
  354.     read()
  355. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement