Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Two sets of linked objects

MikeR Bardach
Registered User
Join date: 22 May 2008
Posts: 9
07-12-2008 23:55
I wonder what is the best way to handle this: Wine bottle (several prims), goblet (several prims). Click on the bottle: I want the bottle to move into position, tilt, and pour into the goblet. Should the bottle prims and the goblet prims be linked? If they are, tilting the bottle tilts the goblet as well (presumably the root prim is in the bottle where I clicked.) I'd need to untilt each of the prims of the goblet.

If they are not linked, how do I tell the goblet what to do (fill with wine = make wine texture visible)? How do I even find where someone has moved the goblet so I can bring the bottle there? Do I need to have them chat with each other: /47 bottle asks wine for location, /47 wine gives location...

What is the best way to handle this?
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
07-13-2008 01:57
Hmmm... Why not just use a sensor?

string Glass = "name_of_the_glass";
integer Handle;

touch_start(integer total)
{
llSensor(Glass, NULL_KEY, SCRIPTED, 96.0, PI); // 96m for a very large castle
}

sensor(integer total)
{
key glass_key = llDetectedKey(0);
ffSlowlyMoveTo(llDetectedPos(0) + some_offset); // Function to write
ffSlowlyRotateToPour(); // Function to write
Handle = llListen(-474747, Glass, glass_key, (string)llGetKey());
llWhisper(-474747, (string)glass_key);
//ffShowWineFlowing(); // Eventually... To look better.
}

no_sensor()
{
llSay(0, "The glass isn't is the house...";);
}

listen(integer channel, string name, key id, string msg)
{
llListenRemove(Handle);
//ffStopFlowOfWine; // Eventually...
ffSlowlyRotateToVertical(); // Function to write
ffSlowlyMoveBack(); // Eventually... Function to write
}

And in the glass:

state_entry()
{
llListen(-474747, "", NULL_KEY, (string)llGetKey());
}

listen(integer channel, string name, key bottle_key, string msg)
{
ffSlowlyFill(); // Function to write
llWhisper(-474747, (string)bottle_key); // I'm full!
}

I made the bottle and the glass talk to each other using their UUID so it's easy to expand the script to let the bottle fill a row of glasses. (That's the most common use of a bottle.) Besides, the UUIDs make good filters to narrow the llListen() "openness".

As for how to fill the glass, it totally depends on the glass. If the glass has a spherical shape like most wine glasses, a dimpled sphere plus a moving/growing disc for the surface will do. You used the word "gobelet", for me that's cylindric. So, a dimpled cylinder that grows with llSetScale() would work in this case. And for the worse cases, a half invisible half transparent texture slowly shifting below an appropriate rising prim surface may be the way to go. Last and simplest solution: llSetAlpha() if everything else fails.
MikeR Bardach
Registered User
Join date: 22 May 2008
Posts: 9
07-13-2008 05:38
Excellent, Kaluura. Thanks.
MikeR Bardach
Registered User
Join date: 22 May 2008
Posts: 9
Choosing Sit on the menu / Run script on rez
07-14-2008 00:03
Follow-up question: I used llSetSitText on the bottle to be Goblet 1, and llSetTouchText to be Goblet 2. So what happens with Goblet 1 is that my avatar sits down on the bottle! Someone suggested that I use llUnSit, so I did that with the code on the LSL Portal, and now the avatar sits down and then gets up. What should I be doing, so that I can detect the Sit without my avatar getting into the act?

Second question: If I just rez a goblet with my script on it, it doesn't seem to do all the initialization steps of the script; the listener never goes on. If I force the script to recompile, then it works fine. Doesn't it run the script whenever I rez it?
MikeR Bardach
Registered User
Join date: 22 May 2008
Posts: 9
07-14-2008 07:13
I got the second part anyhow - llResetScript() for on_rez event...
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
07-14-2008 17:36
If you don't want any AV to sit on a prim, remove the sit target.

llSitTarget(ZERO_VECTOR, ZERO_ROTATION);

And remove the sit text too.

llSetSitText(" ";); // A whitespace, not an empty string.

Beware! Because sit targets have a tendency to stick stronger to prims than their plywood texture. I would (strongly) advice to use fresh prims before to remove the sit target. That should give you a rate of success of 100%... minus some rounding error.