World positon in python

import bge

cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner

own.worldPosition = scene.objects[‘some object’].worldPosition

This is an example of what I’d use if I want to have an object always be in the same world position as another object in my current scene. However, I want an object in my current scene to have the same world position as an object that is in a different scene (let’s say, scene “two”). How do I do that? I know it must be simple but I just can’t find it anywhere online.

I’m assuming instead of “scene = bge.logic.getCurrentScene()” it would be something like “scene = bge.logic.getsomeotherScene()” but I can’t figure it out. Could anyone help with this?

if 'otherScene' not in own
    for scene in bge.logic.getSceneList():
        if 'NameOfScene':
            own['otherScene']= scene

I guess you need a little bit more explanation.

Get all currently running scenes:

scenes = bge.logic.getSceneList()

Now you need something that identifies the scene you want to access. Lets assume you know the name:

sceneName = "Scene"
scenesWithNameScene = [scene for scene in bge.logic.getSceneList() if == sceneName]
aScene = scenesWithNameScene[0]

now you can search for objects in this scene. E.g. when you know the name:

objectName = "Cube"
cubes = [object for object in aScene.objects if == objectName]
aCube = cubes[0]

you can combine this to get all objects of all running scenes:

objectName = "Cube"
cubes = [object for object in scene.objects
            for scene in bge.logic.getSceneList()
         if == objectName]


so you get a list of all objects with the name “Cube”. You can test it by duplicate the default scene via linked objects.
You will get

[Cube, Cube]

I hope it helps

I still can’t get this to work, and I don’t know why the code you two gave me is still hard to understand. Maybe it’s because it has no actual name of my scenes. Sorry still learning python.

My current scene (Scene I am in when starting the game) is called “game”
the other scene is “sun and moon”
the object in the current scene is “Empty”
the object in the “sun and moon” scene is… “sunGraphic”

so it should look like this?..
import bge

if ‘sun and moon’ not in own
for scene in bge.logic.getSceneList():
if ‘game’:
own[‘sun and moon’]= scene

own[‘sun and moon’].objects[‘sunGraphic’].worldPosition=own.scene.objects[‘Empty’].worldPosition

replace “game” with the name of the other scene
sun and moon?

Can’t make it easier then this.

from bge import logic

def get_scene(scene_name):
    scenes = logic.getSceneList()      
    scene = None
    for sce in scenes:
        if == scene_name:
            scene = sce
    if scene == None:     
*** No scene found with the name: ' + str(scene_name) + ' ***
        return scene

def get_object(scene_name, object_name):
    scene   = get_scene(scene_name)
    object  = scene.objects[object_name]
    return object

main_scene_object = get_object('Main_scene_name_here','the_object_name_here')
other_scene_object = get_object('Other_scene_name_here','the_other_object_name_here')

other_scene_object.worldPosition = main_scene_object.worldPosition

Thanks everyone. I got it!