13

I would like to know how to change the values of properties added using the "AddGameProperty" option in the game logic UI using python code? I want to write code that changes the 'Property' value in an Action Actuator logic block. I attached a screenshot for a bit more clarity: How do you change the game properties value to control the action actuator using python code??

David
  • 49,291
  • 38
  • 159
  • 317
CubeBot88
  • 677
  • 2
  • 6
  • 17

2 Answers2

13

If you want to access a property from the current object controller it's :

cont = bge.logic.getCurrentController()
own = cont.owner
my_property=own['propName']

But if you want to access to a property from an other object it's

scene = bge.logic.getCurrentScene()
my_property=scene.objects['other object']['otherpropName']
lucblender
  • 3,333
  • 3
  • 25
  • 36
  • When I get the property using scene it shows only the default property, I don't get the current value of the property which changes as the game progresses. – davidparks21 Nov 28 '17 at 19:44
3

Your question is a bit unclear, but you can use use own['propName'] to access a property

horns
  • 206
  • 1
  • 3