Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- Ticket validating machine
- ---- Tickets are being sold as labeled floppys
- ---- and are used on station to get a train to a demanded destination
- -- os.pullEvent = os.pullEventRaw
- ---- Config
- -- Sides of components
- sides = {}
- sides[1] = "bottom" -- Floppy
- sides[2] = "back" -- Transposer
- sides[3] = "left" -- Dispersers
- sides[4] = "right" -- Rail management
- -- Rails' dispersers' colors
- rails = {}
- rails[1] = colors.white
- rails[2] = colors.orange
- rails[3] = colors.magenta
- rails[4] = colors.lightBlue
- rails[5] = colors.yellow
- rails[6] = colors.lime
- rails[7] = colors.pink
- rails[8] = colors.gray
- transColor = colors.lightGray
- platforms = {}
- platforms[1] = "I"
- platforms[2] = "II"
- platforms[3] = "II"
- platforms[4] = "III"
- platforms[5] = "III"
- platforms[6] = "IV"
- platforms[7] = "IV"
- platforms[8] = "V"
- ---- Functions
- -- Check ticket
- function checkTicket()
- station = disk.getLabel(sides[1])
- write("Wybrano stacje " .. station .. "\n")
- process(station)
- rs.setOutput(sides[2], true)
- os.sleep(0.2)
- rs.setOutput(sides[2], false)
- end
- -- Main processing function
- function process(station)
- if station == "swiatynia" then
- disperse(1)
- elseif station == "wioska" then
- disperse(2)
- manageRails(station)
- elseif station == "krater" then
- disperse(2)
- manageRails(station)
- elseif station == "arena" then
- disperse(7)
- end
- end
- -- Disperser processing function
- function disperse(rail)
- rs.setBundledOutput(sides[3], rails[rail])
- os.sleep(0.2)
- rs.setBundledOutput(sides[3], transColor)
- write("Twoj wagon zostal podstawiony na tor nr " .. rail .. " przy peronie " .. platforms[rail] .. "\n")
- end
- -- Rail managing function
- function manageRails(station)
- if station == "krater" then
- rs.setBundledOutput(sides[4], colors.orange)
- os.sleep(1)
- rs.setBundledOutput(sides[4], colors.black)
- end
- if station == "wioska" then
- rs.setBundledOutput(sides[4], colors.white)
- os.sleep(1)
- rs.setBundledOutput(sides[4], colors.black)
- end
- end
- -- //BLANK
- -- //\BLANK
- ---- Main program
- term.clear()
- term.setCursorPos(1,1)
- write("Prosze umiescic bilet w stacji\n")
- while true do
- if disk.isPresent(sides[1]) then
- checkTicket()
- os.sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- write("Prosze umiescic bilet w stacji\n")
- end
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment