Teleporting Player sometimes crashes the PlayDate

I think it's crashing when it needs to check outside of the play area.

Is there a way for it to also just tell whether or not the tile that it's checking is within the play area or not?

This is roughly what Im doing:

if event.dy==-1 then
blinkX = event.px
blinkY = event.py
blinkY -= 4
blinkTarget = solid blinkX,blinkY
end

	if event.dy==1 then
		blinkX = event.px
		blinkY = event.py
		blinkY += 4
		blinkTarget = solid blinkX,blinkY
	end
	
	if event.dx==-1 then
		blinkX = event.px
		blinkX -= 4
		blinkY = event.py
		blinkTarget = solid blinkX,blinkY
	end
	
	
	if event.dx==1 then
		blinkX = event.px
		blinkX += 4
		blinkY = event.py
		blinkTarget = solid blinkX,blinkY
	end
	
	// if the destination isn't solid, it teleports the player
	
	if blinkTarget==0 then
		sound "blinkSound"
		goto blinkX,blinkY
	end

Not sure why my photo is upside down. It's normal on my PC.

My error is "fatal: unable to get tile at" and then the tile, which seems to always involve a Y coordinate being offscreen. For some reason the X axis off screen tiles just take me off screen.

Is there a way to keep this crashing error from happening?

I tried googling the error, but only found 1 instance of the words " fatal: unable to get tile at" and it was someone commenting on the itch.io page of a PlayDate game saying they were getting crashes.

fixed it.

the error came form checking if a position was solid or not.

If a hypothetical position can ever be checked from a position that doesnt exist (outside of the play area/off screen), it'll crash the game, rather than just return null and move on.

I fixed it by reordering my entire mechanic's functions so that it checks for solid last (since that variable has the most possibilities).

The image is upside down because this web forum software probably isn't handling exif image rotation tags when resizing uploaded images (i.e. it's probably a bug in the forum itself).

It's a bit of image format trivia, but here's a full explanation if you are interested: The dumb reason your fancy Computer Vision app isn’t working: Exif Orientation | by Adam Geitgey | Medium