Module GameTypes :: Class CListValue
[hide private]
[frames] | no frames]

Class CListValue

source code

PyObjectPlus --+        
               |        
          CValue --+    
                   |    
          CPropValue --+
                       |
                      CListValue

CListValue

This is a list like object used in the game engine internally that behaves similar to a python list in most ways.

As well as the normal index lookup. val= clist[i]

CListValue supports string lookups. val= scene.objects["OBCube"]

Other operations such as len(clist), list(clist), clist[0:10] are also supported.

Instance Methods [hide private]
 
append(val)
Add an item to the list (like pythons append)
source code
integer
count(val)
Count the number of instances of a value in the list.
source code
integer
index(val)
Return the index of a value in the list.
source code
 
reverse()
Reverse the order of the list.
source code
 
get(key, default=None)
Return the value matching key, or the default value if its not found.
source code
boolean
has_key(key)
Return True if the key is found.
source code
 
from_id(id)
This is a funtion especially for the game engine to return a value with a spesific id.
source code
    Deprecated
    Inherited from CValue
string
getName()
Returns the name of the CValue.
source code
    Inherited from PyObjectPlus
bool
isA(game_type)
Check if this is a type or a subtype game_type.
source code
Instance Variables [hide private]
    Inherited from CValue
string name
The name of this CValue derived object (read-only).
    Inherited from PyObjectPlus
bool invalid
Test if the object has been freed by the game engine and is no longer valid.
Method Details [hide private]

append(val)

source code 

Add an item to the list (like pythons append)

Warning: Appending values to the list can cause crashes when the list is used internally by the game engine.

count(val)

source code 
Count the number of instances of a value in the list.
Returns: integer
number of instances

index(val)

source code 
Return the index of a value in the list.
Returns: integer
The index of the value in the list.

get(key, default=None)

source code 
Return the value matching key, or the default value if its not found.
Returns:
The key value or a default.

has_key(key)

source code 
Return True if the key is found.
Returns: boolean
The key value or a default.

from_id(id)

source code 

This is a funtion especially for the game engine to return a value with a spesific id.

Since object names are not always unique, the id of an object can be used to get an object from the CValueList.

Example.

myObID = id(gameObject)

...

ob= scene.objects.from_id(myObID)

Where myObID is an int or long from the id function.

This has the advantage that you can store the id in places you could not store a gameObject.

Warning: the id is derived from a memory location and will be different each time the game engine starts.