Telling which scene a player came from

If I have one large scene with several exits that load other scenes, I can load a new scene based on where the player left the big scene. For example, if the player enters one door it can load the kitchen and if he enters another it can load the bedroom. How could I make it so that if the player leaves one of these sub-scenes it will spawn him in the right location in the main scene?

A lot of ways to do it. A good one could be make a dictionary that relates ObjectName/ObjectReference/EmptyName/EmptyReference/ID/IDinProperty/PropertyName/etc… with ObjectName/ObjectReference/… of the other scene. Maybe you may want to add the SceneName/SceneReference/ID/PropertyInMainObject/PropertyNameInMainObject/… etc.

I think that the best match is to use ObjectName -> [SceneName, ObjectName]

So for example you can have a dict like:

doorsPaths = [
"LeftDoorKitchen": ("Bedroom", "RightDoorBedroom"),
"FrontDoorKitchen": ("Outside", "BackDoorOutside"),
"RightDoorBedroom": ("Kitchen", "LeftDoorKitchen"),
"BackDoorOutside": ("Kitchen", "FrontDoorKitchen"),

Notice that with this you can make a door send you to one place when opened from one side and another when opened from the other side.

So basically you would do something like (being player a class that you made):

if player.openedDoor(): player.sendTo(*doorsPaths[player.doorThatPlayerOpened])

and then…

def sendTo(self, scene, place):logic.setScene("") #Or whatever is the BGE API for this
someGlobal = place

And now when loadig the new scene you check someGlobal and spawn/move the player there.

Notice that in BGE core you can use the same Scene Behavior Class in multiple scenes, and therefore you can use a class attribute instead of a global.