Nike622000

Aufzug Hochhaus

Apr 1st, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. local monSide  = "back"
  2. local Position = 1
  3. local Bcol     = colors.lightGray
  4. local bSide    = "right"
  5. local time     = .5
  6.  
  7. mon = peripheral.wrap(monSide)
  8. mon.setTextScale(.5)
  9. xMax,yMax = mon.getSize()
  10.  
  11. Etage    = {}
  12. Etage[1] = { 3, 5,14,13," EG"     ,colors.black  ,colors.blue     ,colors.cyan     ,false}
  13. Etage[2] = {16, 5,27,13," OG 1"   ,colors.black  ,colors.red      ,colors.yellow   ,false}
  14. Etage[3] = {29, 5,40,13," OG 2"   ,colors.black  ,colors.green    ,colors.gray     ,false}
  15. Etage[4] = {42, 5,53,13," OG 3"   ,colors.black  ,colors.orange   ,colors.pink     ,false}
  16. Etage[5] = { 3,15,14,23," OG 4"   ,colors.black  ,colors.lime     ,colors.white    ,false}
  17. Etage[6] = {16,15,27,23," OG 5"   ,colors.black  ,colors.magenta  ,colors.lightGray,false}
  18. Etage[7] = {29,15,40,23," OG 6.1" ,colors.black  ,colors.lightBlue,colors.purple   ,false}
  19. Etage[8] = {42,15,53,23," OG 6.2" ,colors.black  ,colors.brown    ,colors.black    ,false}
  20.  
  21. function JoJa(xP,yP)
  22.   mon.setCursorPos(xP,yP)
  23.   mon.setBackgroundColor(colors.gray)
  24.   mon.setTextColor(colors.cyan)
  25.   mon.write("Jo")
  26.   mon.setTextColor(colors.orange)
  27.   mon.write("Ja ")
  28.   mon.setTextColor(colors.lightGray)
  29.   mon.write("Productions")
  30. end
  31.  
  32. function Background(col)
  33.   mon.setBackgroundColor(col)
  34.   for yPos = 1,yMax do
  35.     for xPos = 1,xMax do
  36.       mon.setCursorPos(xPos,yPos)
  37.       mon.write(" ")
  38.     end
  39.   end
  40.   mon.setCursorPos(xMax/2-3,3)
  41.   mon.setBackgroundColor(colors.red)
  42.   mon.write(" Etage "..Position.." ")
  43. end
  44.    
  45. function drawButton()
  46.   for i = 1,#Etage do
  47.     mon.setTextColor(colors.white)
  48.     mon.setBackgroundColor(Etage[i][6])
  49.     for yPos = Etage[i][2],Etage[i][4] do
  50.       for xPos = Etage[i][1],Etage[i][3] do
  51.         mon.setCursorPos(xPos,yPos)
  52.         mon.write(" ")
  53.       end
  54.     end
  55.     mon.setCursorPos((Etage[i][1]+Etage[i][3])/2-#Etage[i][5]/2,(Etage[i][2]+Etage[i][4])/2)
  56.     mon.write(Etage[i][5])
  57.   end
  58. end
  59.  
  60. function checkButton(xP,yP)
  61.   for i = 1,#Etage do
  62.     if xP >= Etage[i][1] and xP <= Etage[i][3]
  63.     and yP >= Etage[i][2] and yP <= Etage[i][4]
  64.     then
  65.       Etage[i][9] = true
  66.     end
  67.   end
  68. end
  69.  
  70. function move()
  71.   col = 0
  72.   for i = 1,#Etage do
  73.     if Etage[i][9] then
  74.       Etage[i][9] = false
  75.       if Position < i then
  76.         for p = Position,i do
  77.           col = col + Etage[p][7]
  78.           sleep(time)
  79.           rs.setBundledOutput(bSide,col)
  80.         end
  81.       elseif Position > i then
  82.         for p = Position,i,-1 do
  83.           col = col + Etage[p][8]
  84.           sleep(time)
  85.           rs.setBundledOutput(bSide,col)
  86.         end
  87.       end
  88.     end
  89.   end
  90.   rs.setBundledOutput(bSide,0)
  91. end
  92.  
  93. while true do
  94.   Background(Bcol)
  95.   JoJa(xMax/2-7,1)
  96.   drawButton()
  97.   event,_,xPos,yPos = os.pullEvent("monitor_touch")
  98.   checkButton(xPos,yPos)
  99.   move()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment