Talk to Merlin; go through all 3 chat options then all his second 3 chat options.
Click on the vent opposite the gate.
Cast Tele-grab on the Guard fixing his hair outside the gate.
Use the Hairclip on the gate.
Complete the puzzle: To complete this puzzle, you must set each of four tumblers to the correct height. The most foolproof way to do this (although not necessarily the quickest) is to set all tumblers to the lowest height and try the lock. If a tumbler shows a green circle, do not change that tumbler anymore. Ignore blue and red circles. For all the other tumblers, increase the height by one and try again. Continue until the lock unlocks. This method will take at most six attempts.
Once you have bypassed the gate, go up the tower to the top floor.
Kill Sir Mordred if you want.
Search the table and click the purple cylinder second from the right.