Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- V2 Programmed by Rolcam
- Programming Guide:
- Do not save this to startup. I was too lazy to have the program redirect itself to a monitor. Instead, make a basic monitor redirect program for startup. E.g. it's one line and it would be 'shell.run("monitor right slots")' if you have a monitor on the right and saved this program as 'slots'
- Wiring Guide:
- Bundled redstone cables, or any equivalent, are required for this system
- Input/Outputs are on the back side of the computer
- Inventory Inputs are on the bottom of the computer
- Outputs:
- Black band: Door lock
- White Band: Prize 1 - RRR
- Orange Band: Prize 2 - JJJ
- Magenta Band: Prize 3 - III
- Yellow Band: Prize 4 - DDD
- Blue Band: Prize 5 - LLL
- Pink Band: Consolation Prize
- Inputs:
- Light Blue - Release door lock
- Red - Debug mode toggle
- Light Gray - Reset credits
- Brown - Reboot the slot machine
- Lime Band: Payment Pulse - Adds a credit when pulsed
- Green Band: Payment Pulse - 5 Credits
- Gray Band: Payment Pulse - 10 Credits
- Purple Band: Game Start - Begins the game when activated
- To be added:
- Weighted Jackpot (each spin adds 1 to the counter, jackpot variable is random from 1 - 100. If it is less than the counter, the jackpot is won, and the counter is reset. DO NOT make it less than or equals to. This is to make two jackpots in a row impossible. Since the program will reboot often, you cannot save this as a variable. Save it to a file so it can remember the slot count
- Program new slots system
- Togglable debug mode
- ]]--
- os.pullEvent = os.pullEventRaw
- --Debug Variables - Please Ignore
- debug = 0
- prize = 3
- num1 = "-"
- num2 = "-"
- num3 = "-"
- -- Credit Variable - Leave it at 0 unless you are debugging or want to give out free plays for a while
- credits = 0
- -- Check for credit system, leave this alone
- check = 0
- -- Pulse - Used for prizes that get dispensed multiple times when won. This gets set when the prize gets dispensed
- pulse = 0
- -- Obtains spin count - it grabs this from a file so it can remember this between reboots
- if not fs.exists(".data") then
- data = fs.open(".data", "w")
- data.write("1")
- data.close()
- else
- data = fs.open(".data","r")
- slotCountA = data.readLine()
- data.close()
- slotCount = tonumber(slotCountA)
- end
- -- Checks for image data. If they aren't there, it downloads the needed files
- if fs.exists("Frame1") or fs.exists("Frame2") or fs.exists("Frame3") then
- sleep(0.1)
- else
- term.clear()
- term.setCursorPos(10,7)
- print("Getting files...")
- sleep(1)
- shell.run("pastebin","get","0jtcj1F4","Frame1")
- shell.run("pastebin","get","07eWGpLk","Frame2")
- shell.run("pastebin","get","xgqQ1wJ2","Frame3")
- term.setCursorPos(10,9)
- print("Done")
- end
- -- Frame variables - don't touch
- q = paintutils.loadImage("Frame2")
- p = paintutils.loadImage("Frame1")
- s = paintutils.loadImage("Frame3")
- -- Draws the text overlay
- function image()
- paintutils.drawImage(p,1,1)
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- print("Slots V2 by Rolcam")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(12,9)
- if credits == 1 then
- print("You have "..credits.." credit remaining")
- else
- print("You have "..credits.." credits remaining")
- end
- end
- function debugMode()
- --Enter debug stuff here
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- dCheck = 1
- while dCheck == 1 do
- term.clear()
- term.setCursorPos(1,1)
- print("Debug Mode - Activated by Operator")
- print(" ")
- print("Prize Table:")
- print("1 - 777 - Jackpot - Triggers all prizes")
- print("2 - RRR - Prize 1 - White Band")
- print("3 - JJJ - Prize 2 - Orange Band")
- print("4 - III - Prize 3 - Magenta Band")
- print("5 - DDD - Prize 4 - Yellow Band")
- print("6 - LLL - Prize 5 - Blue Band")
- print("7 - Consolation Prize - Pink Band")
- print(" ")
- print("Please select a number from the prize table to force a prize to dispense")
- prize = tonumber(read())
- if tonumber(prize) == nil then
- print("Invalid Selection")
- sleep(3)
- else
- dCheck = 0
- end
- debug = 1
- end
- end
- -- Checks for credits
- if credits == 0 then
- -- Loops until the purple band is pulsed. This is the credits purchase screen
- while check == 0 do
- term.setBackgroundColor(colors.orange)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(10,8)
- print("Please Purchase Credits")
- term.setCursorPos(10,9)
- -- Change the text to whatever you want the player to do or use to trigger the slots. I use a pressure plate due to how the claim plugin works on the server I am using this in.
- print("Step on the pressure plate to start the game!")
- term.setCursorPos(10,10)
- print("Credits Purchased: "..credits.." credits")
- term.setCursorPos(10,11)
- print("Each spin uses one credit")
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- local event = os.pullEvent("redstone")
- if rs.testBundledInput("back", colors.purple) == true then
- check = 1
- -- The server I am using this in has a shop plugin, so I made a redstone circuit to pulse a redstone signal when a purchase was made. You could manually pulse the redstone channel when someone pays ya, or automate it somehow. That part is on you to configure.
- elseif rs.testBundledInput("back", colors.lime) == true then
- credits = credits + 1
- elseif rs.testBundledInput("back", colors.green) == true then
- credits = credits + 5
- elseif rs.testBundledInput("back", colors.gray) == true then
- credits = credits + 10
- elseif rs.testBundledInput("back", colors.lightGray) == true then
- credits = 0
- print("Credits reset by operator")
- sleep(2)
- elseif rs.testBundledInput("back", colors.red) == true then
- debugMode()
- elseif rs.testBundledInput("back", colors.brown) == true then
- print("Rebooting...")
- sleep(3)
- os.reboot()
- end
- sleep(0.1)
- end
- end
- -- If the check is complete and no credits were bought, the system reboots to get back to the purchase screen.
- if credits == 0 then
- print("No credits purchased! Rebooting...")
- sleep(3)
- os.reboot()
- end
- -- Door Lock (Wiring this up is optional)
- redstone.setBundledOutput("back", colors.black)
- -- Main Program
- while true do
- term.setBackgroundColor(colors.orange)
- term.clear()
- term.setTextColor(colors.white)
- -- Ends game if credits run out
- if credits <= 0 then
- term.clear()
- term.setCursorPos(10,8)
- print("You are out of credits")
- print(" ")
- term.setCursorPos(10,10)
- print("Game Over!")
- redstone.setBundledOutput("back", 0)
- sleep(3)
- term.setBackgroundColor(colors.black)
- term.clear()
- os.reboot()
- end
- -- Draws the slots
- image()
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- term.setCursorPos(6,13)
- print(">")
- term.setCursorPos(16,13)
- if num1 == 1 then
- print("7")
- elseif num1 == 2 then
- print("R")
- elseif num1 == 3 then
- print("J")
- elseif num1 == 4 then
- print("I")
- elseif num1 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(26,13)
- if num2 == 1 then
- print("7")
- elseif num2 == 2 then
- print("R")
- elseif num2 == 3 then
- print("J")
- elseif num2 == 4 then
- print("I")
- elseif num2 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(36,13)
- if num3 == 1 then
- print("7")
- elseif num3 == 2 then
- print("R")
- elseif num3 == 3 then
- print("J")
- elseif num3 == 4 then
- print("I")
- elseif num3 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(46,13)
- print("<")
- local event = os.pullEvent("redstone")
- if rs.testBundledInput("back", colors.lime) == true then
- credits = credits + 1
- term.setCursorPos(1,43)
- print("Purchased 1 Slot Credit")
- elseif rs.testBundledInput("back", colors.green) == true then
- credits = credits + 5
- term.setCursorPos(1,43)
- print("Purchased 5 Slot Credits")
- elseif rs.testBundledInput("back", colors.gray) == true then
- credits = credits + 10
- term.setCursorPos(1,43)
- print("Purchased 10 Slot Credits")
- elseif rs.testBundledInput("back", colors.lightGray) == true then
- credits = 0
- term.setCursorPos(1,43)
- print("Credits reset by operator")
- elseif rs.testBundledInput("back", colors.red) == true then
- debugMode()
- elseif rs.testBundledInput("back", colors.brown) == true then
- print("Rebooting...")
- sleep(3)
- os.reboot()
- elseif rs.setBundledInput("back", colors.lightBlue) == true then
- rs.setBundledOutput("back", 0)
- elseif rs.testBundledInput("back", colors.purple) == true then
- credits = credits - 1
- spinSlots = 1
- paintutils.drawImage(s,1,1)
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- sleep(0.2)
- paintutils.drawImage(q,1,1)
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- sleep(0.2)
- paintutils.drawImage(s,1,1)
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- sleep(0.2)
- image()
- term.setCursorPos(1,17)
- print("Jackpot win chance is: " .. slotCount - 1 .. "%")
- -- Jackpot Weight System
- jackpotWin = math.random(1,100)
- if jackpotWin < slotCount then
- jackpot = 1
- else
- jackpot = 0
- end
- -- Updates the slot count and writes to the file
- slotCount = slotCount + 1
- data = fs.open(".data", "w")
- data.write(slotCount)
- data.close()
- -- Code the slots system here
- spin1 = 20
- spin2 = 30
- spin3 = 40
- num1 = 1
- num2 = 2
- num3 = 3
- -- Reel Spin Code
- while spinSlots == 1 do
- if spin1 > 0 then
- num1 = math.random(1,6)
- spin1 = spin1 - 1
- elseif debug == 1 then
- num1 = prize
- elseif num1 ~= 1 and jackpot == 1 then
- num1 = 1
- end
- if spin2 > 0 then
- num2 = math.random(1,6)
- spin2 = spin2 - 1
- elseif debug == 1 then
- num2 = prize
- elseif num2 ~= 1 and jackpot == 1 then
- num2 = 1
- end
- if spin3 > 0 then
- num3 = math.random(1,6)
- spin3 = spin3 - 1
- else
- if debug == 1 then
- num3 = prize
- elseif num3 == 1 and jackpot == 0 then
- num3 = math.random(2,6)
- elseif num3 ~= 1 and jackpot == 1 then
- num3 = 1
- end
- end
- if (spin1 <= 0) and (spin2 <= 0) and (spin3 <= 0) then
- spinSlots = 0
- end
- if debug == 1 then
- num3 = prize
- elseif num3 == 1 and jackpot == 0 then
- num3 = math.random(2,6)
- elseif num3 ~= 1 and jackpot == 1 then
- num3 = 1
- end
- term.setCursorPos(6,13)
- print(">")
- term.setCursorPos(16,13)
- if num1 == 1 then
- print("7")
- elseif num1 == 2 then
- print("R")
- elseif num1 == 3 then
- print("J")
- elseif num1 == 4 then
- print("I")
- elseif num1 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(26,13)
- if num2 == 1 then
- print("7")
- elseif num2 == 2 then
- print("R")
- elseif num2 == 3 then
- print("J")
- elseif num2 == 4 then
- print("I")
- elseif num2 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(36,13)
- if num3 == 1 then
- print("7")
- elseif num3 == 2 then
- print("R")
- elseif num3 == 3 then
- print("J")
- elseif num3 == 4 then
- print("I")
- elseif num3 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(46,13)
- print("<")
- sleep(0.1)
- end
- if debug == 1 then
- num3 = prize
- elseif num3 == 1 and jackpot == 0 then
- num3 = math.random(2,6)
- elseif num3 ~= 1 and jackpot == 1 then
- num3 = 1
- end
- term.setCursorPos(6,13)
- print(">")
- term.setCursorPos(16,13)
- if num1 == 1 then
- print("7")
- elseif num1 == 2 then
- print("R")
- elseif num1 == 3 then
- print("J")
- elseif num1 == 4 then
- print("I")
- elseif num1 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(26,13)
- if num2 == 1 then
- print("7")
- elseif num2 == 2 then
- print("R")
- elseif num2 == 3 then
- print("J")
- elseif num2 == 4 then
- print("I")
- elseif num2 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(36,13)
- if num3 == 1 then
- print("7")
- elseif num3 == 2 then
- print("R")
- elseif num3 == 3 then
- print("J")
- elseif num3 == 4 then
- print("I")
- elseif num3 == 5 then
- print("D")
- else
- print("L")
- end
- term.setCursorPos(46,13)
- print("<")
- -- Checks if you won a prize
- if (num1 == num2) and (num2 == num3) then
- if num3 == 1 then
- term.setCursorPos(18,18)
- print("JACKPOT! Win chance will now be reset!")
- slotCount = 1
- data = fs.open(".data", "w")
- data.write(1)
- data.close()
- pulse = 6
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors. orange, colors.pink))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- pulse = 5
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors. white, colors.blue, colors.yellow))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- pulse = 4
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.magenta))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- else
- term.setCursorPos(18,18)
- print("You won! Now dispensing prize " .. num1 .."!")
- if num1 == 2 then
- pulse = 5
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.white))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- elseif num1 == 3 then
- pulse = 6
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.orange))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- elseif num1 == 4 then
- pulse = 4
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.magenta))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- elseif num1 == 5 then
- pulse = 5
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.yellow))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- elseif num1 == 6 then
- pulse = 5
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.blue))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- end
- end
- -- Prize Dispense Code
- else
- term.setCursorPos(1,18)
- print("No match.... Dispensing consolation prize!")
- pulse = 6
- while pulse > 0 do
- rs.setBundledOutput("back", colors.combine(colors.black, colors.pink))
- sleep(0.1)
- rs.setBundledOutput("back", colors.black)
- sleep(0.1)
- pulse = pulse - 1
- end
- -- Consolation Prize
- end
- end
- end
Add Comment
Please, Sign In to add comment