make the object's current name the name of a global property?(python)

let’s say I got the object’s name via python and stored it in a variable called name then wanted to make a global property of GameLogic.[object’s current name] doing

doesn’t work so how would I do it?

What doesn’t work? Saving a name property in GameLogic works fine for me…

For example:

import GameLogic as g

cont = g.getCurrentController() =

And then I have another script…


Which correctly prints out the first object’s name…


since 2.49 object names are read only, renaming caused problems

Python script error from controller “cont#CONTR#2”:
Traceback (most recent call last):
File “”, line 29, in <module>
AttributeError: “name” is read only

How about you save it to a dictionary instead?

### Initiate the dictionary ###
if not hasattr(GameLogic, "myObjects"):
    GameLogic.myObjects = []

### Assigning the global variable  ###
obj = GameLogic.getCurrentController().owner

GameLogic.myObjects[] = obj # Put whatever value you wanted to put here

I’ll try that thanks.

Ah, maybe I misunderstood what you meant? I thought you wanted to save the name property of an object and put it in GameLogic… but you want to change the name of an object instead?

Can you explain a bit more as to why you need to do it / what use it has to change the name? You could always just have a string property on the object which you could change…