Create invisibly doors in all the entrances and add an instance variable "Door_Number" then set each door with its own unique number: 1,2,3, etc...
Supposing that the Cave is in a separate layout:
You need to repeat the same process and create all the invisible doors with the same "Door_Number" unique number: 1,2,3, etc...That you set it up above.
1-Then on colliding with any door to enter the cave save the "Door_Number" in a global variable, Array, Dictionary, or whatever method you like.
2-On Cave Layout:
-At the start of the layout:
----------Door.Door_Number = Global Var "Door_Number": ---------Action:Set Character Position to DoorX,Y