Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- side2 = "back"
- term.clear()
- term.setCursorPos(1,1)
- print("Please Insert Vend Pass")
- event, side = os.pullEvent("disk")
- print("Pass Inserted")
- print("Beginning Security Check")
- sleep(0.5)
- if fs.exists("disk/startup") then
- term.setTextColor(colors.red)
- print("WARNING: Startup Program Detected!")
- c = 0
- while tk == 1 do
- -- If a program called startup_#### doesn't exist then:
- if not fs.exists("startup_" .. c) then
- -- resets security variable
- tk = 0
- -- stores a copy of the startup program to the computer as "startup_####"
- shell.run("copy disk/startup", "startup_" .. c)
- else
- -- Increases the number by 1
- sleep(0.1)
- c = c + 1
- end
- -- Deletes the startup program on the floppy disk
- shell.run("delete disk/startup")
- print("Program logged and deleted!")
- sleep(0.5)
- print("Confiscating disk...")
- sleep(0.5)
- -- Ejects disk then reboots the computer
- disk.eject(side)
- os.reboot()
- end
- end
- -- Checks if a data disk was inserted or if a random object was inserted instead
- if not disk.hasData(side) then
- term.setTextColor(colors.red)
- print("Warning: Invalid Object Detected!")
- sleep(0.5)
- print("Confiscating item. Please see zoo staff for retrieval")
- sleep(2)
- disk.eject("bottom")
- os.reboot()
- end
- if not fs.exists("disk/.credits") then
- term.setTextColor(colors.red)
- print("Disk doesn't have credit pass data!")
- sleep(0.5)
- print("Confiscating disk. Please see zoo staff for retrieval")
- sleep(2)
- disk.eject("bottom")
- os.reboot()
- end
- rID = disk.getID(side)
- if rID == 5 or rID == 11 then
- term.setTextColor(colors.red)
- term.clear()
- term.setCursorPos(1,1)
- print("Admin Card Detected")
- print("Additional Options Unlocked")
- sleep(2)
- end
- while true do
- --Checks Balance
- creditDat = fs.open("disk/.credits","r")
- credits2 = creditDat.readLine()
- creditDat.close()
- -- Main Screen
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- print("Condemned Zoo Vending Machine System V1\n ")
- credits = tonumber(credits2)
- print("You currently have ".. credits .." credits on your card")
- if credits > 0 then
- print("Please select your requested item #")
- print("1 - Splash Health Potion II - 50 credits")
- print("2 - Saddles - 10 credits")
- print("3 - Diamond Horse Armor - 20 credits")
- print("4 - End Transaction")
- if rID == 5 or rID == 11 then
- term.setTextColor(colors.orange)
- print("5 - Enter Maintenance Mode")
- end
- term.setTextColor(colors.yellow)
- input = read()
- if input == "1" then
- if rs.testBundledInput(side2, colors.lime) == false then
- if credits >= 50 then
- credits = credits - 50
- creditUp = fs.open("disk/.credits","w")
- creditUp.writeLine(credits)
- creditUp.close()
- print("Now Vending Item 1")
- rs.setBundledOutput(side2, colors.white)
- sleep(0.1)
- rs.setBundledOutput(side2, 0)
- sleep(1)
- print("Check chest for item")
- sleep(2)
- end
- else
- term.setTextColor(colors.red)
- print("Sold Out :(")
- sleep(2)
- end
- elseif input == "2" then
- if rs.testBundledInput(side2, colors.pink) == false then
- if credits >= 10 then
- credits = credits - 10
- creditUp = fs.open("disk/.credits","w")
- creditUp.writeLine(credits)
- creditUp.close()
- print("Now Vending Item 2")
- rs.setBundledOutput(side2, colors.orange)
- sleep(0.1)
- rs.setBundledOutput(side2, 0)
- sleep(1)
- print("Check chest for item")
- sleep(2)
- end
- else
- term.setTextColor(colors.red)
- print("Sold Out :(")
- sleep(2)
- end
- elseif input == "3" then
- if rs.testBundledInput(side2, colors.gray) == false then
- if credits >= 20 then
- credits = credits - 20
- creditUp = fs.open("disk/.credits","w")
- creditUp.writeLine(credits)
- creditUp.close()
- print("Now Vending Item 3")
- rs.setBundledOutput(side2, colors.magenta)
- sleep(0.1)
- rs.setBundledOutput(side2, 0)
- sleep(1)
- print("Check chest for item")
- sleep(2)
- end
- else
- term.setTextColor(colors.red)
- print("Sold Out :(")
- sleep(2)
- end
- elseif input == "4" then
- term.clear()
- term.setCursorPos(1,1)
- print("Thank you for using the condemned zoo vending system")
- print("Don't forget to take your pass")
- sleep(5)
- print("Auto ejecting pass")
- sleep(2)
- disk.eject(side)
- os.reboot()
- elseif input == "5" and (rID == 5 or rID == 11) then
- print("Entering Maintenance Mode")
- break
- else
- term.setTextColor(colors.red)
- print("Invalid Selection")
- sleep(2)
- end
- else
- term.setTextColor(colors.red)
- print("You are out of credits")
- disk.setLabel(side,"Empty Pass")
- sleep(0.5)
- print("Confiscating empty pass")
- sleep(0.5)
- print("See guest services for a new credit pass")
- sleep(2)
- disk.eject(side)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement