I was curious about the python code I could use to set a game property as a global value and call it from another object?
What I usually do is have a “master” object like an empty and I give it the properties to hold. Then I can just access the property from that one object whenever I need to.
script 1
## Method 1 ##
global MYVAR
MYVAR = "totally cool"
## Method 2 ##
bge.logic.NEWVAR = "nice"
script 2
## Method 1 ##
global MYVAR
print(MYVAR)
## Method 2 ##
print(bge.logic.NEWVAR)
but method 1 can get a bit messy sometimes.
A) Search the object
B) get the property from it
objectWithProperty = scene.objects["ObjectWithProperty"]
propertyValue = objectWithProperty["propertyName"]
drawback -> You need to know the internal structure of the other object (-> the object name + property name).
Dependent on the purpose of the property/property value there might be other solutions.