Jump to content

Help with rezzing code


Laura Demme
 Share

You are about to reply to a thread that has been inactive for 4570 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi all!

I've been working on a freebie rezzing script, trying to adapt it to my needs.  Here's my latest issue:

This script gets the location/rotation for the rezzed object from lines of code within the script itself, that must be entered by hand.  I'd like the script to be able to recognize and update the position of the rezzed object, like when re-arranging furniture in a room, etc.  Currently, when the rezzed object is moved/adjusted, then re-rezzed, it returns to its original location.  Is it possible to have this single script update positions all by itself?

I think a second script (for the rezzed object) may be needed, but I'm not sure.  If this is the case, how would I get the rezzed object to report a position change to the rezzer, and get the rezzer to recognize and update the objects position?

I've searched the LSL Wiki, and see that there are ways for scripts to communicate with each other, but I haven't a clue how to make this work.  Can anyone help?

Thanks so much!

Link to comment
Share on other sites

The most straightforward solution I can think of is to put a simple script in the object that you rez that reports its own position if you click on it. In simple form ...

 

integer gChan;default{    on_rez (integer startup)    {        gChan = startup;    }    touch_start (integer num)    {        if (lDetectedKey(0) == llGetOwner())        {            llSay(gChan, "Sofa" + (string) llGetPos() + (string)llGetRot());        }    }}

 The rezzer passes the sofa a chat channel number as it is rezzed and then listens on that channel for the message that's sent when you click on the sofa.  It parses the message, recognizes that it's the sofa speaking, and updates the position and rotation so that they are ready if you ever want to re-rez a sofa in that spot.  Of course, the update values will be lost if you ever reset the rezzer's script, but if you don't have a lot of furniture to manage you can find ways to store the information in less volatile places like its object description.

 

Link to comment
Share on other sites

Hi Rolig,

The script you posted woked perfectly.  Unfortunately, after several hours of tinkering, I couldn't get the rezzer script to react to it.  I keep trying, but learning LSL has been quite a challenge for me.

I think I've reached the point of exasperation with this project.  I may have to contract someone, or I don't think I'll ever finish.

Thanks so much for your help! :matte-motes-grin:

Link to comment
Share on other sites

Don't give up now.  You can figure this one out.  When I wrote that short script, it included a line in the on_rez event that grabs a startup parameter.  That's a good way to pass a communication channel number from the rezzer to the new object.  In the rezzer script, you need a corresponding line that says something like

llRezAtRoot( object_name, llGetPos() + offset_vector * llGetRot(), ZERO_VECTOR, object_rot, channel_number);

The variable channel_number is the channel that your sofa will speak on, and that the rezzer will listen on.  That's what the object hears as its startup parameter.  So, the rezzer script needs to create that channel_number, open a listen handle, and contain a listen event in which it receives and interprets messages from your rezzed bjects.

The object_name is obviously the name of the sofa or whatever you are rezzing.

The offset_vector is just <Stored_object_position> - llGetPos() , where <Stored_object_position> is the vector that your sofa sends back when you touch it.  The object_rot is the stored rotation that it sends in the same message.

The rest of the rezzer script is all about how you receive, parse, and store the information you need.

Work on writing the script in modules, one little bit at a time.  When you get stuck, post  back here to see if we can help you get unstuck.

 

Link to comment
Share on other sites

  • 2 weeks later...

Well, it was more than a few days, but I'm back to this project.  I did get that last line of code working (thanks again, Rolig!).  Then as I was re-reading this thread, and I thought about your (Rolig) comment about notecards.  That might be a better way to approach this.  I found a couple of notecard scripts and have been working with those.  WHEN I get stuck again (and I know I will!)  I will be back for more guidance.

Thanks to all!  I don't post very often, but I read the scripting threads a lot, and it's always been a huge help!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4570 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...