Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rezz Object script

Lilyanah Demar
Working to make SL my RL
Join date: 15 Apr 2006
Posts: 212
05-08-2008 15:41
I need a rezz object script ... I bought one but it is no trans... I need a script that will rezz an object when the prim is sat on.. ((ie a book for reading animation.. etc.) Any ideas?
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
05-08-2008 16:16
CODE

integer rezzed;
string object;
default
{
state_entry()
{
rezzed = 0;
objectname = llGetInventoryName(INVENTORY_OBJECT, 0);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if(rezzed == 0)
{
llRezObject(objectname, <0,0,0.5>, <0,0,0>, ZERO_ROTATION, 42);
rezzed = 1;
}
else if(rezzed == 1)
{
rezzed = 0;
}
}
}
}


This has not been tested in-world, and is off the top of my head. It will rez the first object found in it's inventory half a meter above the rezzer prim, when sat on. It shouldn't rez another when the person stands up, but will rez another when sat on again, so be careful that you use temp and such.

Again, not tested in-world, not guaranteeing accuracy.
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Keira Moxie
Registered User
Join date: 17 Dec 2005
Posts: 47
05-16-2008 09:51
hmm.. tried that script..thank you for the help... but no it didn't work... anyone else available or have any ideas?
Mereille Despres
Registered User
Join date: 5 Sep 2007
Posts: 79
05-16-2008 11:14
This should work. (I haven't tested it inworld) Basically, I fixed what Kiera posted earlier:
There are two scripts here, the first for the object to be sat on, the other for the object to be rezzed.

Look me up in world if you need any more help. : ) (Scripting is my life, lol )

//This will rez the first object in the containing object's inventory
//when someone sits on it.
integer rezzed;
string objectname;
default
{
state_entry()
{
rezzed = 0;
objectname = llGetInventoryName(INVENTORY_OBJECT, 0);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
//see if someone is sitting
key av = llAvatarOnSitTarget();
if (av)
{
if(rezzed == 0)
{
llRezObject(objectname, llGetPos() + <0,0,0.5>, ZERO_VECTOR, ZERO_ROTATION, 0);
rezzed = 1;
}
}
else //make sure the thing goes away
{
llWhisper(-8120,"Die";);
rezzed = 0;
}
}
}
}

/////////////////////////////////////////////////////////////
// Put this in the object you are rezzing if you want it to
// disappear when the avatar stands back up.
/////////////////////////////////////////////////////////////
default
{
state_entry()
{
llListen(-8120,"","","Die";);
}

listen(integer channel, string str, key id)
{
llDie();
}
}
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
05-16-2008 11:58
Just a small correction to the script...state entry is triggered when: State is entered and script is restted, so:

This should work. (I haven't tested it inworld) Basically, I fixed what Kiera posted earlier:
There are two scripts here, the first for the object to be sat on, the other for the object to be rezzed.

Look me up in world if you need any more help. : ) (Scripting is my life, lol )

//This will rez the first object in the containing object's inventory
//when someone sits on it.
integer rezzed;
string objectname;
default
{
state_entry()
{
rezzed = 0;
objectname = llGetInventoryName(INVENTORY_OBJECT, 0);
}

on_rez(integer number)
{
llResetScript();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
//see if someone is sitting
key av = llAvatarOnSitTarget();
if (av)
{
if(rezzed == 0)
{
llRezObject(objectname, llGetPos() + <0,0,0.5>, ZERO_VECTOR, ZERO_ROTATION, 0);
rezzed = 1;
}
}
else //make sure the thing goes away
{
llWhisper(-8120,"Die";);
rezzed = 0;
}
}
}
}
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
05-16-2008 12:00
ehehe..fix fix fix....

I love the scripting forum, everything is so interesting .__.
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL