Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Coffee machines

Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
10-02-2004 03:50
I want to make a script for a coffee machine that will give whoever touches it a cup of coffee that will attach and animate them (with permission of course).

I can make it rez a cup of coffee, I can make the cup attach and animate, but at the moment I can only make it attach to the owner of the coffee machine. I can, and indeed have, grabbed the key from the touch so I can give it to the toucher (but not make it animate them, just go into their inventory), is there any way to make it attach to the toucher, or to pass the key from the touched coffee machine to the cup of coffee it rezes?
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
10-02-2004 22:28
set the script for coffee cup on rez to detect if it was resed by person or object. If it was rezed by an object, tell the script to lessen on a channel. Perhaps channel 120, if you want to add some security you could hard code the coffee machine's key into the lesson, So it won't lessen to any other objects talking on channel 120. Set the lessen to convert any message it receives into a key. Turn off the lessen, and Then use the key to attach the coffee cup.

Then set the coffee machine to rez the cup, wait say 5 second, and then say on channel 120 the key of the person who touched the coffee machine.

if you don't mind me asking how do you get the script to rez a copy of the coffee cup, instead of razzing the original coffee cup?
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
10-02-2004 22:45
Here is an example, but this is a really bad example. This is a script I hacked together to experiment.

CODE
key drum = NULL_KEY; 
integer stick = 0;
integer channel = 51;
string lastMessage;
key user = NULL_KEY;

default
{
state_entry()
{
llListen( channel, "", drum, "" );
}

listen( integer channel, string name, key id, string message )
{
if ( lastMessage == (string)stick )
{
user = (key)message;
llRequestPermissions(user, PERMISSION_ATTACH);
lastMessage = message;
}
else if ( user != NULL_KEY && message == "off")
{
llDetachFromAvatar();
user == NULL_KEY;
}
else
{
lastMessage = message;
}
}

run_time_permissions(integer perm)
{
if (perm == PERMISSION_ATTACH)
{
llAttachToAvatar(ATTACH_LHAND);
}
}
}
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
10-03-2004 03:28
Thank you for this, i will give it a go.

I actually make it rez a copy of the coffee cup, because I want it to dispense multiple cups, but if the object inside is no copy it will rez the original.
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
10-03-2004 12:39
An object can only be attached to its owner, not to anyone else, so you'll have to give the object to the person and let them attach it themselves.
Sue Stonebender
Piano Craftsman
Join date: 7 Jan 2005
Posts: 219
Question ...
10-15-2005 20:48
This is an interesting dilemma. I'm curious about something ...

Sometimes when you purchase a box of clothes, it will automatically put them on you unelss you uncheck the wear box. It recognizes that they're wearable objects, and when you buy them, you become the owner. You don't have to drag them out of your inventory. It just puts them on you. How does that happen?

Following the logic of this example, would it not make sense that a coffee cup -- or other object designed to attach to a certain body part -- could automatically be worn when dispensed from the parent object too?
_____________________