Advertisement
AdamMathieson

cc_door_ctrl

Aug 5th, 2022 (edited)
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. local monitors = {
  2.     "monitor_12",
  3.     "monitor_13"
  4. }
  5.  
  6. local motor = peripheral.wrap("electric_motor_3")
  7.  
  8. motor.setSpeed(5)
  9.  
  10. for i,m in ipairs(monitors) do
  11.     local mon = peripheral.wrap(m)
  12.     mon.setBackgroundColour(colours.black)
  13.     mon.setTextScale(0.5)
  14.     mon.clear()
  15.     mon.setCursorPos(1,1)
  16.     mon.blit("                                ", "00000000000000000000000000000000", "55555555555555555555555555555555")
  17.     mon.setCursorPos(1,2)
  18.     mon.blit("                                ", "00000000000000000000000000000000", "55555555555555555555555555555555")
  19.     mon.setCursorPos(1,3)
  20.     mon.blit("                                ", "00000000000000000000000000000000", "55555555555555555555555555555555")
  21.     mon.setCursorPos(1,4)
  22.     mon.blit("                                ", "00000000000000000000000000000000", "55555555555555555555555555555555")
  23.    
  24.    
  25.     mon.setCursorPos(1,6)
  26.     mon.blit("                                ", "00000000000000000000000000000000", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  27.     mon.setCursorPos(1,7)
  28.     mon.blit("                                ", "00000000000000000000000000000000", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  29.     mon.setCursorPos(1,8)
  30.     mon.blit("                                ", "00000000000000000000000000000000", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  31.     mon.setCursorPos(1,9)
  32.     mon.blit("                                ", "00000000000000000000000000000000", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  33.     mon.setCursorPos(1,10)
  34.     mon.blit("                                ", "00000000000000000000000000000000", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
  35.    
  36.     mon.setCursorPos(6,3)
  37.     mon.blit("OPEN", "0000", "5555")
  38.     mon.setCursorPos(5,9)
  39.     mon.blit("CLOSE", "fffff", "eeeee")
  40. end
  41.  
  42. local function has_value (tab, val)
  43.     for index, value in ipairs(tab) do
  44.         if value == val then
  45.             return true
  46.         end
  47.     end
  48.  
  49.     return false
  50. end
  51.  
  52. while true do
  53.   local event, side, x, y = os.pullEvent("monitor_touch")
  54.   if has_value(monitors, side) then
  55.     if y > 5 then
  56.         print("Sending door UP")
  57.         motor.setSpeed(-64)
  58.     else
  59.         print("Sending door UP")
  60.         motor.setSpeed(64)
  61.     end
  62.   end
  63. end
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement