So I took a pawn on d5 with my knight to entice the queen to take, thus opening up the d file. The idea being that I would castle queen side, trapping his queen. I can't work out why it won't let me castle. I haven't moved the king (I even tested it on the previous move to see that it was still possible). I'm kinda new to learning so it might be something obvious, but I can't work it out.
Can't work out why I can't castle


You can't castle when your king is in check, when your king ends up in check, or when your rook ends up in check. The last one is the case here.
EDIT: You also can't castle when your rook has moved, or when your king has moved. In case you didn't know.

Ah, I didn't realize that the rook couldn't be in check. Damn, sacked that knight for nothing then. Thanks !

I should have said when the rook ends up being attacked. Of course the rook can never be 'in check'. Lol brain fart.
Sorry, but that's not quite correct. The only constraint against the rook is that it must be an original rook, and it must not have moved. (note the careful phrasing - this is to prevent anyone crazy enough to promote on e8 to a rook, then castle with that rook) Therefore, the rook is not the problem here.
The real reason is that in addition to not being able to castle "from" and "into" check, you cannot castle "through" check either. Here, castling queenside takes your king through d1, which is attacked by the queen. Since transiting this square is castling "through" check, you can't do it. Of course, you can still play Rd1.

+1 As above, you can't Castle through check.
FIDE Laws of Chess. The moves of the pieces.
Artical 3.8
b. (1) The right to castle has been lost:[a]if the king has already moved, or[b]with a rook that has already moved.
(2) Castling is prevented temporarily:
[a] if the square on which the king stands, or the square which it must cross, or the square which it is to occupy, is attacked by one or more of the opponent's pieces, or
[b] if there is any piece between the king and the rook with which castling is to be effected.
Source FIDE Laws of Chess or maybe have a look through the chess.com notes and videos on how to play chess & rules
You may also want to brush up on the 'en passant' rule too.

I understand why you would want to castle it's a excellent move because it would be pinning the queen and king.

Somewhat surprising that someone who has played 1659 games on the site would not be aware of the rules of castling.

If you look at White's position with the Knight on h8, Queen on g4 and with both Rooks, Bishop and King on their starting squares its clear that many games does not a chess player make.

Made_in_Shoreditch true but it would improve you kings position because there is not much pressure on the queen side and better pawn structure

I don't know, he's actually just outplayed his opponent and taken advantage of mistakes to reach that position. Anyway, it's an ongoing game so probably best not to comment further.

Made_in_Shoreditch true but it would improve you kings position because there is not much pressure on the queen side and better pawn structure
White cannot castle in this position, it is illegal. He should play Rd1 and win the game easily.

But we're talking about if he could castle and in the REAL position not the one Strangemover made the queen was NEVER on G5

What I posted is the current position - the game is still ongoing. The OP asked about castling in the position after blacks move 18 caps lock guy.