Guest User

startup

a guest
Jan 6th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. --[[
  2. Symulator Windy 2018. by Google
  3. --]]
  4.  
  5. monitor = "top" -- strona monitora
  6. strona = "bottom" -- strona kabla
  7. akp = 1 -- pietro na ktorym jest pc
  8.  
  9. os.unloadAPI("kapi")
  10. os.loadAPI("kapi")
  11.  
  12. 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}
  13. tablica = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
  14.  
  15. function bc (color, aha)
  16.  if aha then
  17.   rs.setBundledOutput(strona, color)
  18.   end
  19.   if not aha then
  20.   col = rs.getBundledInput(strona)
  21.   rs.setBundledOutput(strona, 0)
  22.  end
  23. end
  24.  
  25. function detectLevel ()
  26.  for i = 1, 13 do
  27.   det = rs.getBundledInput(strona)
  28.   if colors.test(det, kolory[i]) == false then
  29.    dor = i - 1
  30.    break
  31.   end
  32.  end
  33.  return dor
  34. end
  35.  
  36. function wDol (ile)
  37.  ile2 = ile * 9
  38.  winda = detectLevel()
  39.  a2 = winda - ile
  40.  if a2 == 1 then
  41.   ile2 = ile2 + 9
  42.  end
  43.  if a2 == 0 then
  44.   ile2 = ile2 - 2
  45.  end
  46.  if ile > 1 then
  47.   ile2 = ile2 + 9
  48.  end
  49.  for i = 1, ile2 do
  50.   sleep(0.1)
  51.   bc(colors.red, true)
  52.   sleep(0.8)
  53.   bc(colors.red, false)
  54.  end
  55.  ile2 = 0
  56. end
  57.  
  58. function wGore (ile)
  59.  local ile = ile * 9
  60.  winda = detectLevel()
  61.  if winda == 1 then
  62.   ile = ile + 9
  63.  end
  64.  if winda == 0 then
  65.   ile = ile - 2
  66.  end
  67.  if winda == 0 then
  68.   if ile > 10 then
  69.    ile = ile + 9
  70.   end
  71.  end
  72.  for i = 1, ile do
  73.   sleep(0.1)
  74.   bc(colors.black, true)
  75.   sleep(0.8)
  76.   bc(colors.black, false)
  77.  end
  78. end
  79.  
  80. function writeMenu (table)
  81.  term.clear()
  82.  a = 1 + akp  
  83.  while true do
  84.   for i = 1, #table do
  85.    term.setCursorPos(1, 1)
  86.    kapi.centerPrint("Wybierz pietro:")
  87.    term.setCursorPos(1, 2)
  88.    kapi.writeLine()
  89.    term.setCursorPos(1, i + 3)  
  90.    term.clearLine()
  91.    kapi.centerPrint(table[i])
  92.   end
  93.   term.setCursorPos(1, a + 3)
  94.   term.clearLine()
  95.   local d1 = table[a]
  96.   kapi.centerPrint("[".. d1.. "]")
  97.   local event, key = os.pullEvent("key")
  98.   if key == 208 and a<#table then
  99.    a = a + 1
  100.   elseif key == 200 and a>1 then
  101.    a = a - 1
  102.   elseif key == 28 then
  103.    jedz(a-1, "Winda odjedzie za kilka sekund")
  104.    sleep(1)
  105.    break
  106.   end
  107.  end
  108. end
  109.  
  110. function jedz (pietro, tekst)
  111.  local winda = detectLevel()
  112.  if pietro < winda then
  113.   local nato = winda - pietro
  114.   sleep(1)
  115.   term.clear()
  116.   kapi.centerText(tekst)
  117.   sleep(3)
  118.   wDol(nato)
  119.  end
  120.  if pietro > winda then
  121.   local  nato = pietro - winda
  122.   term.clear()
  123.   kapi.centerText(tekst)
  124.   sleep(3)
  125.   wGore(nato)  
  126.  end
  127. end
  128.  
  129. function przywolaj ()
  130.  term.clear()
  131.  kapi.centerText("Winda Przyjedzie za kilka sekund.")
  132.  sleep(1)
  133.  jedz(akp)
  134. end
  135.  
  136. function dis ()
  137.  while true do
  138.   if not detectLevel() == nil then
  139.   else
  140.    term.setCursorPos(1, 17)
  141.    kapi.writeLine()
  142.    term.setCursorPos(1, 16)
  143.    term.clearLine()
  144.    kapi.centerPrint("Winda znajduje sie na pietrze: ".. detectLevel())
  145.   end
  146.   sleep(0.5)
  147.  end
  148. end
  149.  
  150. while true do
  151.  term.clear()
  152.  kapi.centerText("Nacisnij 'Enter' aby przywolac winde.")
  153.  event, key = os.pullEvent("key")
  154.  if key == 28 then
  155.   jedz(akp, "Winda przyjedzie za chwile.")
  156. --  parallel.waitForAll(writeMenu(tablica), dis())
  157.   writeMenu(tablica)
  158.  end
  159. end
Advertisement
Add Comment
Please, Sign In to add comment