monitor = peripheral.wrap("left")
door = true
function rndl()
  return string.char(math.random(97,122));
end
function doorctrl(d)
  redstone.setOutput("right",door)
  return not d
end

while true do
  for i = 1, 29, 1 do
    for t = 1, 19,1 do
      local event, param = os.pullEvent("key")
      if event == "key" then
        doorctrl(door)
        door = not door
      end
      print(i.." "..t)
      monitor.setCursorPos(i,t)
      monitor.write(rndl())
      --monitor.write("a")
      sleep(0.1)
    end
    door = doorctrl(door)  
  end
end
