Hi José Rodolfo Rosa escribió: > > Hi, > > I have created a simple property class that has only one action, which > has a string as one of its parameters. It is working perfectly in a > python behaviour. > > > The problem is that I want to return a string to the property class at > the end of the execution of the action. I have some questions > concerning that. > >
I think you're using incorrect terminology. By your code below, i understand you're sending a message from your property class, and the behaviour answers in its message callback, called listen_listener, in your case. Then, you want to return some value from the message callback. > 1) To return a value to a property class i must use the celData ret > parameter, right? > > No. Normally from cel python you dont work with celData, they will always be transformed to the right python type, and when you have to return a celData from a method (like a behaviour message response), just return the appropriate python datatype. > 2) When I use iCelBehaviour::SendMessage one of the parameters is > celData &ret, but in the action definition on the python behaviour > there is no such parameter. So, how can I return a value to a property > class from a python behaviour? > > The input parameter is converted into an output parameter in the python side. So, just return the value, at least it should work well with simple python types (str,bool,float,int), im not sure about returning cs or cel objects though (like an entity pointer). The value should appear in the celData parameter. > Following is a piece of code from my python behaviour which > implmements the action from my property class so you can better > understand my questions: > > > def __init__(self,celEntity): > > . . . > > . . . > > . . . > > self.listenertest = celListener(celEntity) > > . . . > > . . . > > . . . > > def listen_listener(self,pc,args): > > msg = "Test" > > if(args.GetParameter(0) == msg): > > print “OK” > > > where listen_listener is the action I have created in my pcListener > property class. “OK” appears correctly in the console. > > > 3) The comparison in the action, args.GetParameter(0) returns celData > which is compared to a string and returns true. How does it work? > > As explained above, the celData is automatically converted to python. Also, you should be able to just use args[name], instead of args.GetParameter() (recommended syntax is documented in the cel manual). > 4) Finally, I'd like to know what do I need to do to return a string > to my property class in the execution of the action. > > Mmm, same question again? :). Just return the string. I hope i answered all your questions. Greetings. Pablo ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Cel-main mailing list Cel-main@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cel-main