Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Start a script only when sitting on the prim

Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
12-15-2007 09:53
Hi guys,

I have this nice bouncing script from the forums that I am modifying for use in a pogo stick. It works quite well, except for two things:

1. It starts bouncing on_rez, and I would like it it to only start when I get on it

2. It only bouces on land, not on solid objects such as floors of house. Is there an alternative event to the land_collision event?

CODE

default
{
on_rez(integer x)
{
llResetScript();
}

state_entry()
{
llSetStatus(STATUS_PHYSICS,TRUE);
llSetStatus(STATUS_PHANTOM,TRUE);
llCollisionSound("c02681b3-52f3-dfa0-416b-3f414fb01aef",1);
}

land_collision_start(vector x)
{
llSetStatus(STATUS_PHYSICS,FALSE);
llSetPos(llGetPos() + <0,0,2>);
llSetStatus(STATUS_PHYSICS,TRUE);
}
}


any suggestions, as ever, appreciated

Rock
Starfire Desade
Can I play with YOUR mind
Join date: 10 Jul 2006
Posts: 404
12-15-2007 10:26
Look up info on the "changed(integer change)" event... specifically, the "CHANGED_LINK" portion, which can tell if someone is sitting on the item.
Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
12-15-2007 14:50
From: Starfire Desade
Look up info on the "changed(integer change)" event... specifically, the "CHANGED_LINK" portion, which can tell if someone is sitting on the item.


Thanks for that Starfire, it looks like what I need. I have tried to work this out from scratch, step-by-step, using the standard 'get off!' script. As I am going to introduce the land collision event later, I first want the rezzed object to be clearly off the ground. Unfortunately the code i have tried does not work, and in fact putting a llSay(0, "Hi there";); inside the on_rez state results in nothing being said at all. Why is my on_rez state not functioning as I think it should?

CODE


default {
on_rez(integer x)
{
llResetScript();
llSitTarget(<0, 0, 0.1>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
llSetPos(llGetPos() + <0.0, 0.0, 3.0>); // Ensure rezzed prim is not touching the land
}

changed(integer change)
{
if (change & CHANGED_LINK)
{ // if something changed AND it was a link change
key av = llAvatarOnSitTarget();
if (av)
{
llSay(0, "Get off!"); // say in chat when person is remove from prim
llUnSit(av); // unsit him
}
}
}
}


TIA

Rock
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-15-2007 15:07
it was a simple mistake, on_rez() means when it is first spawned from a object or item,

you need a llSiTarget in state_entry() after on_rez()


CODE

default
{
on_rez() // whne first rezes
{
//stuff
}
state_entry() // everytime scritp restarts
{
//stuff
}
Dewcati Benelli
Registered User
Join date: 25 Feb 2007
Posts: 2
Start script form different prim while sitting on another
12-23-2007 12:13
I have a carosel and want rotation to start once avi is seated on a prim, rotation script is in another prim. Is there a way to have the rotation script start once the avi is seated in the other prim?

Thanks
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-23-2007 20:29
From: Dewcati Benelli
I have a carosel and want rotation to start once avi is seated on a prim, rotation script is in another prim. Is there a way to have the rotation script start once the avi is seated in the other prim?

Thanks

assuming the other script is running, and waiting for an event, send it a message to start/stop when an av is detected, or better just do that IN the rotation script. something like

changed( integer vIntChanged ){
if (llAvatarOnSitTarget()){
//-- do rotation
}
}

if the script isn't running, you'd need a script in the same prim that turns it on, something like the above, but instead of //-- do rotation you do womething like

if (llAvatarOnSitTarget()){
llSetScriptState( "rotationScriptName", TRUE );
}else{
llSetScriptState( "rotationScriptName", FALSE );
}

the first example is better for most uses
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -