Add attribute to entity (Python)


I wanted to add an attribute to Ship object to be able to track it throughout the game. Something like this:
self.destination = None
in the __init__ function.

But it seems that each turn it is initialised as if a new object was created. I.e., in the beginning of each turn, it’s None over and over.

Could you please help find the solution to this?

Values of objects not changing in list after modification - python
Can Ship ID change from frame to frame?

Create dict like targets[]=position. It is the easiest solution.


Thank you for the reply! That’s exactly how I do it now. But I’d still like to use attributes, if there’s a way.


There are plans in the works for persistent ship instances between turns.

See here and here.

I wrote and have been using the _generate solution just fine.