Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Symulator Windy 2018. by Google
- --]]
- monitor = "top" -- strona monitora
- strona = "bottom" -- strona kabla
- akp = 1 -- pietro na ktorym jest pc
- os.unloadAPI("kapi")
- os.loadAPI("kapi")
- kolory = {colors.purple, colors.white, colors.orange, colors.magenta, colors.lightBlue , colors.yellow , colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.blue, colors.brown}
- tablica = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
- function bc (color, aha)
- if aha then
- rs.setBundledOutput(strona, color)
- end
- if not aha then
- col = rs.getBundledInput(strona)
- rs.setBundledOutput(strona, 0)
- end
- end
- function detectLevel ()
- for i = 1, 13 do
- det = rs.getBundledInput(strona)
- if colors.test(det, kolory[i]) == false then
- dor = i - 1
- break
- end
- end
- return dor
- end
- function wDol (ile)
- ile2 = ile * 9
- winda = detectLevel()
- a2 = winda - ile
- if a2 == 1 then
- ile2 = ile2 + 9
- end
- if a2 == 0 then
- ile2 = ile2 - 2
- end
- if ile > 1 then
- ile2 = ile2 + 9
- end
- for i = 1, ile2 do
- sleep(0.1)
- bc(colors.red, true)
- sleep(0.8)
- bc(colors.red, false)
- end
- ile2 = 0
- end
- function wGore (ile)
- local ile = ile * 9
- winda = detectLevel()
- if winda == 1 then
- ile = ile + 9
- end
- if winda == 0 then
- ile = ile - 2
- end
- if winda == 0 then
- if ile > 10 then
- ile = ile + 9
- end
- end
- for i = 1, ile do
- sleep(0.1)
- bc(colors.black, true)
- sleep(0.8)
- bc(colors.black, false)
- end
- end
- function writeMenu (table)
- term.clear()
- a = 1 + akp
- while true do
- for i = 1, #table do
- term.setCursorPos(1, 1)
- kapi.centerPrint("Wybierz pietro:")
- term.setCursorPos(1, 2)
- kapi.writeLine()
- term.setCursorPos(1, i + 3)
- term.clearLine()
- kapi.centerPrint(table[i])
- end
- term.setCursorPos(1, a + 3)
- term.clearLine()
- local d1 = table[a]
- kapi.centerPrint("[".. d1.. "]")
- local event, key = os.pullEvent("key")
- if key == 208 and a<#table then
- a = a + 1
- elseif key == 200 and a>1 then
- a = a - 1
- elseif key == 28 then
- jedz(a-1, "Winda odjedzie za kilka sekund")
- sleep(1)
- break
- end
- end
- end
- function jedz (pietro, tekst)
- local winda = detectLevel()
- if pietro < winda then
- local nato = winda - pietro
- sleep(1)
- term.clear()
- kapi.centerText(tekst)
- sleep(3)
- wDol(nato)
- end
- if pietro > winda then
- local nato = pietro - winda
- term.clear()
- kapi.centerText(tekst)
- sleep(3)
- wGore(nato)
- end
- end
- function przywolaj ()
- term.clear()
- kapi.centerText("Winda Przyjedzie za kilka sekund.")
- sleep(1)
- jedz(akp)
- end
- function dis ()
- while true do
- if not detectLevel() == nil then
- else
- term.setCursorPos(1, 17)
- kapi.writeLine()
- term.setCursorPos(1, 16)
- term.clearLine()
- kapi.centerPrint("Winda znajduje sie na pietrze: ".. detectLevel())
- end
- sleep(0.5)
- end
- end
- while true do
- term.clear()
- kapi.centerText("Nacisnij 'Enter' aby przywolac winde.")
- event, key = os.pullEvent("key")
- if key == 28 then
- jedz(akp, "Winda przyjedzie za chwile.")
- -- parallel.waitForAll(writeMenu(tablica), dis())
- writeMenu(tablica)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment