Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap( "left" )
- local stationNames = {"RedwoodFactory", "SlimeVille", "EmeraldValley", "Coppertino"}
- local stationFullNames = {"Redwood Factory", "Slime Ville", "Emerald Valley", "Coppertino"}
- function writeDepartures()
- monitor.setCursorPos( 3, 2 )
- monitor.blit(" ", "ffffffffffffffffffffffffffffffffff", "feeffeeeeffeeeffeeffeeeefeeeffeffe")
- monitor.setCursorPos( 3, 3 )
- monitor.blit(" ", "ffffffffffffffffffffffffffffffffff", "effefeffeffffefeffeffffefeffefeffe")
- monitor.setCursorPos( 3, 4 )
- monitor.blit(" ", "ffffffffffffffffffffffffffffffffff", "effefeffeffffefeffefffeffeffeffeef")
- monitor.setCursorPos( 3, 5 )
- monitor.blit(" ", "ffffffffffffffffffffffffffffffffff", "effefeffefeffefeeeeffefffeffefffef")
- monitor.setCursorPos( 3, 6 )
- monitor.blit(" ", "ffffffffffffffffffffffffffffffffff", "feeffeeefffeeffeffefeeeefeeeffffef")
- end
- function writeTimeTable()
- monitor.setBackgroundColor( colors.black )
- monitor.setTextColor( colors.white )
- monitor.setCursorPos( 2, 8 )
- monitor.write("Lp. | Kierunek | Do odjazdu")
- monitor.setCursorPos( 2, 9 )
- monitor.write("1 | ----------------- | ----------")
- monitor.setCursorPos( 2, 10 )
- monitor.write("2 | ----------------- | ----------")
- monitor.setCursorPos( 2, 11 )
- monitor.write("3 | ----------------- | ----------")
- monitor.setCursorPos( 2, 12 )
- monitor.write("4 | ----------------- | ----------")
- monitor.setCursorPos( 2, 13 )
- monitor.write("5 | ----------------- | ----------")
- monitor.setCursorPos( 2, 14 )
- monitor.write("6 | ----------------- | ----------")
- monitor.setCursorPos( 2, 15 )
- monitor.write("7 | ----------------- | ----------")
- monitor.setCursorPos( 2, 16 )
- monitor.write("8 | ----------------- | ----------")
- monitor.setCursorPos( 2, 17 )
- monitor.write("9 | ----------------- | ----------")
- monitor.setCursorPos( 2, 18 )
- monitor.write("10 | ----------------- | ----------")
- end
- function fetchTrain()
- local trainFetched = false
- if (colors.test (redstone.getBundledInput("right"), colors.blue)) then
- print("Pociag czeka na peronie odjazdow")
- else
- sleep(1)
- redstone.setBundledOutput("top", colors.pink)
- sleep(1)
- trainFetched = true
- end
- redstone.setBundledOutput("top", 0)
- return trainFetched
- end
- function addDeparture(name, timeLeft)
- monitor.setBackgroundColor( colors.black )
- monitor.setTextColor( colors.white )
- -- time
- local nameTrimmed = ""
- if string.len(name) > 17 then
- nameTrimmed = string.sub(name, 0, 17)
- else
- nameTrimmed = name
- end
- monitor.setCursorPos(8, 9)
- monitor.write(" ")
- monitor.setCursorPos(28, 9)
- monitor.write(" ")
- monitor.setCursorPos(8, 9)
- monitor.write(nameTrimmed)
- monitor.setCursorPos(28, 9)
- monitor.write(timeLeft)
- end
- -- 47s
- function announceTrain(name)
- local timeLeft = 5
- local timeLeftText = string.format("%d s", timeLeft)
- local ticketPrinter = peripheral.wrap("back")
- ticketPrinter.createTicket(name, 1)
- ticketPhase = 0
- while (timeLeft ~= 0) do
- timeLeftText = string.format("%d s", timeLeft)
- addDeparture(name, timeLeftText)
- timeLeft = timeLeft - 1
- sleep(1)
- if ticketPhase == 0 then
- redstone.setOutput("bottom", true)
- ticketPhase = ticketPhase + 1
- elseif ticketPhase == 1 then
- redstone.setOutput("bottom", false)
- ticketPhase = ticketPhase + 1
- end
- end
- addDeparture("-----------------", "----------")
- os.shutdown()
- end
- function createMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Witaj!")
- term.setCursorPos(1,2)
- term.write("Wybierz prosze numer stacji do ktorej chcesz jechac")
- for i=1, table.getn(stationNames) do
- term.setCursorPos(1,2 + i)
- term.write(string.format("%d. %s", i, stationFullNames[i]))
- end
- term.setCursorPos(1, 3 + table.getn(stationNames))
- term.setCursorBlink(true)
- local input = read()
- input = tonumber(input)
- term.setCursorPos(1, 4 + table.getn(stationNames))
- local valueValid = false
- if input then
- if input >= 1 and input <= table.getn(stationNames) then
- valueValid = true
- end
- end
- term.setCursorPos(1, 4 + table.getn(stationNames))
- if valueValid then
- term.write(string.format("Wybrales stacje %s", stationFullNames[input]))
- if fetchTrain() then
- term.setCursorPos(1, 5 + table.getn(stationNames))
- term.write("Prosze czekac. Twoj pociag niebawem przyjedzie")
- announceTrain(stationNames[input])
- else
- sleep(5)
- end
- else
- term.write("Wprowadziles niepoprawna wartosc")
- sleep(5)
- end
- end
- function main()
- writeDepartures()
- writeTimeTable()
- --announceTrain("SlimeVille")
- while true do
- os.queueEvent("randomEvent")
- os.pullEvent()
- createMenu()
- end
- --if (fetchTrain() == true) then
- -- announceTrain("Dupa")
- --end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment