Earlier in this thread there was the problem of sending multiple messages to the same actuator. I’ve gotten around this as follows:
Make an single empty named “Generic Message” with lots of message actuators, more than the number of messages you’ll ever create during the execution of one python contoller. (And make certain that this empty registers itself in the GameLogic.Objects dictionary as per the original post in this thread.)
Then I import the following code in my python controllers:
MessageActuatorCounter=0
def GenericMessage(To, Subject, Body):
global MessageActuatorCounter #Number of the actuator we're going to use
done=0;
while not done:
try:
aXu= "act"+ "%d" % MessageActuatorCounter; # Actuator's name
# print aXu;
act=GameLogic.Objects["Generic Message"].getActuator(aXu);
except:
MessageActuatorCounter=0; # Loop around to the first one again.
else: done=1
act.setToPropName(To); # Message Receivers must have this property
act.setSubject(Subject); # Message has this subject.
act.setBody(Body);
GameLogic.addActiveActuator(act,1) # do it.
#use next actuator next time
MessageActuatorCounter=MessageActuatorCounter+1;
The advantage is that now I can just use the command
GenericMessage(To, Subject, Body)
to send messages from Python to anybody anytime anywhere.
Note, there are no errors generated! If you use up alotment of messages before your contoller exits, they loop around and you overwrite your earlier messages. EEK. Bad. If anyone comes up with an easy fix for this, let me know.
Presumably one can do this with all sorts of actuators, at least the types that are easily definable using python. Perhaps a class that handles the incrementing and subclasses of that class define the actual values to be set in the actuator…
i’m trying to follow the way you describe it, but i have the problem, that the property-sensor seems to be triggered BEFORE the always sensor …
so GameLogic.Objects is empty for me. i tried to use 2 property sensors, but it seems, that there’s an index which object gets initialised first … so this didnt help.
it seems i mixed something up. the object from Blender.Object.Get("") is a blender not a GameLogic object (different class hirarchy i think).
sorry, allready deleted my post
that is basically result of the unfortunate fact that the game engine is not as well integrated to the rest of Blender as it could be (there is this other old engine, Enji, where you can use the normal Blender API but it’s otherwise not as featureful as Ketsji (the current engine))
i tried it, but objectList is empty, speak [,]. somehow you have to register a object with a scene (maybe link it).
any ideas? the scene would be handy if it worx.