Nike622000

Tueren

Feb 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1.  
  2. local MonSide = "back"
  3. local Bside   = "front"
  4.  
  5. local Bcol    = colors.lightGray
  6.  
  7. mon = peripheral.wrap(MonSide)
  8.  
  9. local xMax,yMax = mon.getSize()
  10.  
  11.  
  12. Door    = {}
  13. Door[1] = { 2, 3,10, 6,"Haustuer",colors.pink   ,false}
  14. Door[2] = {12, 3,20, 6,"Bad"     ,colors.lime   ,false}
  15. Door[3] = {22, 3,30, 6,"Tuer 3"  ,colors.magenta,false}
  16. Door[4] = {32, 3,40, 6,"Tuer 4"  ,colors.cyan   ,false}
  17. Door[5] = { 2, 8,10,11,"Tuer 5"  ,colors.white  ,false}
  18. Door[6] = {12, 8,20,11,"Tuer 6"  ,colors.orange ,false}
  19. Door[7] = {22, 8,30,11,"Tuer 7"  ,colors.green  ,false}
  20. Door[8] = {32, 8,40,11,"Tuer 8"  ,colors.lime   ,false}
  21.  
  22. function JoJa(xP,yP)
  23.   mon.setCursorPos(xP,yP)
  24.   mon.setBackgroundColor(colors.gray)
  25.   mon.setTextColor(colors.cyan)
  26.   mon.write("Jo")
  27.   mon.setTextColor(colors.orange)
  28.   mon.write("Ja ")
  29.   mon.setTextColor(colors.lightGray)
  30.   mon.write("Productions")
  31. end
  32.  
  33. function checkButton(xP,yP)
  34.   for i = 1,#Door do
  35.     if xP >= Door[i][1] and xP <= Door[i][3] and
  36.        yP >= Door[i][2] and yP <= Door[i][4]
  37.        then
  38.        if Door[i][7] then
  39.          Door[i][7] = false
  40.        else
  41.          Door[i][7] = true
  42.        end
  43.     end
  44.   end  
  45. end
  46.  
  47. function checkButton2()
  48.   for i = 1,#Door do
  49.     if colors.test(rs.getBundledInput(Bside),Door[i][6]) then
  50.       Door[i][7] = true
  51.     else
  52.       Door[i][7] = false
  53.     end
  54.   end
  55. end
  56.  
  57. function openDoor()
  58.   rs.setBundledOutput(Bside,0)
  59.   for i = 1,#Door do
  60.     if Door[i][7] then
  61.       rs.setBundledOutput(Bside,rs.getBundledOutput(Bside)+Door[i][6])
  62.     end
  63.   end
  64. end
  65.  
  66. while true do
  67.   mon.setBackgroundColor(Bcol)
  68.   mon.clear()
  69.   JoJa(xMax/2-8,1)
  70.  
  71.   for d = 1,#Door do
  72.     if Door[d][7] then
  73.       mon.setBackgroundColor(colors.lime)
  74.     else
  75.       mon.setBackgroundColor(colors.red)
  76.     end
  77.     for xPos = Door[d][1],Door[d][3] do
  78.       for yPos = Door[d][2],Door[d][4] do
  79.         mon.setCursorPos(xPos,yPos)
  80.         mon.write(" ")  
  81.       end
  82.     end
  83.     mon.setTextColor(colors.white)
  84.     mon.setCursorPos(Door[d][1]+((Door[d][3]-Door[d][1])/2)-(#Door[d][5]/2),Door[d][2]+((Door[d][4]-Door[d][2])/2))
  85.     mon.write(Door[d][5])
  86.   end
  87.   event,timerID,xPos,yPos = os.pullEvent()
  88.   if event == "monitor_touch" then
  89.     checkButton(xPos,yPos)
  90.   end
  91.   openDoor()
  92.   --checkButton2()
  93. end
Advertisement
Add Comment
Please, Sign In to add comment