Thanks a lot for your clarify explanation.
Carlos M. Lorenzo

On 12 mar, 08:07, Toni Alatalo <ant...@kyperjokki.fi> wrote:
> Carlos kirjoitti:
>
>
>
> > I like to know how call a prim method from another prim in python. I
> > like to write a python script to change the texture URL of a prim when
> > I touch another prim. I m using the touch event and the
> > rexSetTextureMediaURL() method.
>
> I'm not sure what' the best way, was actually hoping that perhaps Tuomo
> who wrote the rexscript system would reply. Perhaps Mikko knows too, he
> has been writing some rexscripts now that perhaps refer to other objects
> as well?
>
> At least there seems to be this in the World object: def
> GetActorByLocalID(self,vLocalID) like shown 
> inhttp://forge.opensimulator.org/gf/project/modrex/scmsvn/?action=brows...
> <http://forge.opensimulator.org/gf/project/modrex/scmsvn/?action=brows...>
> . Actor refers to another object which is using some rexscript class and
> is hence registered to the rexscript system.
>
> The prob there is that localids are not good though 'cause they change
> when the server is restarted, you probably want to use the UUID or the name?
>
> We (at Playsign) have now actually started writing apps that use the
> whole region, and not just a single object, as normal OpenSim region
> modules but using Python like in rexscript. So can reload them live,
> without restarting the server, like rexscripts, and get the other
> benefits of py vs c# too. In that case the Opensim Scene objects
> provides methods to get an object either by name or uuid, as shown in
> Scene::GetSceneObjectPart(string name) and friends 
> inhttp://docs.opensimulator.org/classOpenSim_1_1Region_1_1Framework_1_1...
>
> . RexScripts have always been similar to Opensim region modules anyway,
> in the sense they can do anything with the scene, access anything in
> Opensim etc.
>
> We'll probably commit the Python region module loader soon to ModRex,
> perhaps submit it to Opensim core too 'cause it's not rex specific (but
> does use the same ironpy lib as modrex uses otherwise too).
>
> Hopefully there's a simple way for the same in rexscript already for
> you, though.
>
> If rexscript doesn't provide this, you can perhaps use normal python
> stuff to share references. E.g. make an own module (file, defines a
> namespace in py) which several rexscripts can use. E.g. scene.py in the
> same dir where you have the scripts. It can actually be even an empty
> file for this to work, but nicer is to initialize the
> variables/references there:
>
> contents of file scene.py:
> a = None
>
> Then you can use that new module to share a reference to the object you
> wanna call:
>
> script for object A:
> import rxactor
> import scene
>
> class A(rxactor.Actor):
>     def __init__(self, id):
>
>         super(A, self).__init__(id)
>
>         scene.a = self
>
>     def do_stuff(self):
>         print "here we go!"
>
> script for object B:
>
> import rxactor
>
> import scene
> class B(rxactor.Actor):
>     def EventTouch(self, avatar):
>         a = scene.a
>         if a is not None:
>             a.do_stuff()
>         else:
>             print "OOPS, ref to a was not there (yet?)"
>
> normally you could call a.setMediaUrl() etc. directly from B, but recalling 
> from reading the sources of the rexscript impl once it can be that the 
> internals of it do some tricks where have a notion of a 'current object' for 
> the execution, so the calls to the script engine funcs for A from B may not 
> work right. Solutions would be either to send the event which triggers 
> SetMediaURL somehow, or in A.do_stuff put the command in a queue, and have a 
> periodically called update method there (with a rexscript Timer i guess) that 
> does the setting.
>
> The new solution to use normal region modules doesn't have that
> strangeness, is normal Python where objects can call other objects which
> further call the opensim or modrex internals normally etc. If it is
> problematic in current rexscript somehow, we should probably plan a
> refactor of the rexscript system to improve it, perhaps simplify to be
> closer to normal region modules .. especially if the upcoming opensim
> scene refactor results in a nice API (like it of course should!). Basics
> of Rexscript has been basically untouched for 1,5 - 2 years now.
>
> > Carlos Miguel Lorenzo
>
> ~Toni

-- 
http://groups.google.com/group/realxtend
http://www.realxtend.org

Reply via email to