Nike622000

Aufzug neu

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