MagmaLP

Piston Door [2]

Jan 20th, 2021 (edited)
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.81 KB | None | 0 0
  1. --Hilfs-Funktionen--
  2.  
  3. function color(color)
  4.     mon.setTextColor(color)
  5. end
  6.  
  7. function pos(gap, line)
  8.     mon.setCursorPos(gap1,line1)
  9. end
  10.  
  11. function msg(gap, line, color, groundb, text)
  12.     if color == 1 then
  13.         color = 1
  14.     elseif color == 02 then
  15.         color = 2
  16.     elseif color == 03 then
  17.         color = 4
  18.     elseif color == 04 then
  19.         color = 8
  20.     elseif color == 05 then
  21.         color = 16
  22.     elseif color == 06 then
  23.         color = 32
  24.     elseif color == 07 then
  25.         color = 64
  26.     elseif color == 08 then
  27.         color = 128
  28.     elseif color == 09 then
  29.         color = 256
  30.     elseif color == 10 then
  31.         color = 512
  32.     elseif color == 11 then
  33.         color = 1024
  34.     elseif color == 12 then
  35.         color = 2048
  36.     elseif color == 13 then
  37.         color = 4096
  38.     elseif color == 14 then
  39.         color = 8192
  40.     elseif color == 15 then
  41.         color = 16384
  42.     elseif color == 16 then
  43.         color = 32768
  44.     end
  45.  
  46.     if groundb == 1 then
  47.         groundb = 1
  48.     elseif groundb == 02 then
  49.         groundb = 2
  50.     elseif groundb == 03 then
  51.         groundb = 4
  52.     elseif groundb == 04 then
  53.         groundb = 8
  54.     elseif groundb == 05 then
  55.         groundb = 16
  56.     elseif groundb == 06 then
  57.         groundb = 32
  58.     elseif groundb == 07 then
  59.         groundb = 64
  60.     elseif groundb == 08 then
  61.         groundb = 128
  62.     elseif groundb == 09 then
  63.         groundb = 256
  64.     elseif groundb == 10 then
  65.         groundb = 512
  66.     elseif groundb == 11 then
  67.         groundb = 1024
  68.     elseif groundb == 12 then
  69.         groundb = 2048
  70.     elseif groundb == 13 then
  71.         groundb = 4096
  72.     elseif groundb == 14 then
  73.         groundb = 8192
  74.     elseif groundb == 15 then
  75.         groundb = 16384
  76.     elseif groundb == 16 then
  77.         groundb = 32768
  78.     end
  79.  
  80.     mon.setBackgroundColor(groundb)
  81.     mon.setCursorPos(gap,line)
  82.     mon.setTextColor(color)
  83.     text = mon.write(text)
  84. end
  85.  
  86. --Hauptfunktionen--
  87.  
  88. function green()
  89.     msg(1,1,1,6,"          ")
  90.     msg(1,2,1,6,"          ")
  91.     msg(1,3,1,6,"          ")
  92.     msg(1,4,1,6,"          ")
  93.     msg(1,5,1,6,"          ")
  94.     msg(1,6,1,6,"          ")
  95. end
  96.  
  97. function red()
  98.     msg(1,1,1,15,"          ")
  99.     msg(1,2,1,15,"          ")
  100.     msg(1,3,1,15,"          ")
  101.     msg(1,4,1,15,"          ")
  102.     msg(1,5,1,15,"          ")
  103.     msg(1,6,1,15,"          ")
  104. end
  105.  
  106. mon = peripheral.wrap("top")
  107. mon.clear()
  108. red()
  109.  
  110. while true do
  111.     local event, side, X, Y = os.pullEvent("monitor_touch")
  112.     if X >= 1 and X <=10 and Y >= 1 and Y <= 5 and side == "top" then
  113.         green()
  114.         rs.setOutput("back",true)  
  115.         sleep(5)
  116.         rs.setOutput("back",false)  
  117.         red()
  118.  
  119.     elseif rs.getInput("back") then
  120.         green()
  121.         sleep(5)
  122.         red()      
  123.     end
  124.     sleep(0.5)
  125. end
Add Comment
Please, Sign In to add comment