Get Property from a Scene while in annother

Warning to viewers this is my first real attemp at a python script, besides
print: “Hello World” and I’m not ever sure thats right. Any ways I’m trying to send a property from an object to be recieved by an object in a different scene and vice versa
ex. Health to Hud.

I want the blender communitty to look at this python and tell me if what I’m doing is getting on to something great, or is a complete load of junk and the python community shames me. Either way I need some feedback. I found functions


 
import bpy
 
 
#get scenes
CurrentScene = Scene.GetCurrent()
 
InfoScene = Scene.Get(Info)
 
#get object
Sender = bpy.data.objects['object1']
 
Reciever = bpy.data.objects['object2']
 
SenderProperty = Sender.getProperty(Health)
 
SenderData = SenderProperty.getData()
 
RecieverProperty = Reciever.getProperty(Health)
 
RecieverData = RecieverProperty.getData()
 
SenderData == RecieverData
 
#If that doesn't work maybe this will
Sender.getAllProperties()
 
Sender.copyAllPropertiesTo(Reciever)
 

but just looking at this script I see but don’t know where my mistakes are.

Well, your script’s not junk by any means, but the problem that you’re having is that the BGE doesn’t use BPY - it uses the bge Python module. So, if you want to get a property from an object in another scene:



from bge import logic # Import the logic module from the bge module (logic has lots of stuff for game logic, as you can see below)

sce = logic.getCurrentScene() # Get the current game scene, if you want it.

scelist = logic.getSceneList() # Get a list of all active scenes.

acertainsce = [s for s in scelist if 'thenameofthescene' in s.name][0] # Get a particular scene by name, if you KNOW that the scene is present.

anobject = sce.objects['Cube'] # Get the object named 'Cube' in the current scene.(assuming you've got an object named 'Cube' in the current scene, of course)

print ("I'm at: ", anobject.worldPosition) # Prints the cube's world position to the console 


EDIT: Hah, Monster’s pic strikes again. :wink: