Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting touch_start problems

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-20-2006 17:49
I have a prim that is set to sit on touch. Once the avatar is sitting on it, it would be very helpful if I can detect if the avatar clicks on it again.

Is it possible from LSL to change the sit on touch to touch after the avatar sits on it?
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-20-2006 18:48
Yes, when the AV touches it to begin with, after making them sit on it, have the script go to a different state, such as SittingOnPrim. Then you can use a new touch start command to do what ever you like.

Here is an example for you:

CODE



default
{
state_entry()
{
llSay(0, "ready");
}

touch_start(integer total_number)
{
llSay(0,"they are now sitting on me");
state SittingOnPrim;
}

}
state SittingOnPrim
{
state_entry()
{
llSay(0,"I am in the sitting on prim state waiting for another touch");
}
touch_start(integer total_number)
{
llSay(0,"I am now doing another touch activated thing");
state default;
}
}
_____________________
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
12-20-2006 21:35
I don't think that you get a touch event when a prim is set to sit on left click is left clicked, and I don't see a way to change that behavior from a script... so the sitter would have to right-click and select Touch from the pie menu.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
12-21-2006 06:27
From: Boss Spectre
I don't think that you get a touch event when a prim is set to sit on left click is left clicked, and I don't see a way to change that behavior from a script... so the sitter would have to right-click and select Touch from the pie menu.

Boss is right. So you don't need an extra touch event. Just touch to sit and then right click/touch to activate. But what I do in my teleport bubble is touch to sit and then "changed" will detect the sit and activate the teleport.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-24-2006 12:05
Im trying to get the state thing working but no success.

I have the prim w/ left-click set to sit.

CODE

changed(integer change) { // something changed
if (change & CHANGED_LINK) { // and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me


//enter sitting state
state sitting;
}
}
}


state sitting
{
//touching the prim should mean the avatar wants off
touch_start(integer total_number)
{
//unsit the avatar
llUnSit(llGetOwner());
llDie();
}
}


But even with this, the left-click is still only doing the sit action.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
12-24-2006 12:25
There are a couple of problems. Number one, your if test is not working. You can see it by using the script with debug llOwnerSay's in it. Number Two, Left click will still always do just sit. After you are sitting, you will have to right click and then pick "Touch" and it will unsit you and the object will die.
EDIT: So you have three choices. Left click sits you and then right click/touch unsits you and dies OR,
Right click/sit and then left click unsits you and then dies OR,
Put in another changed event and then you left click sit and when you stand up the other changed event fires and the object dies.
CODE
default{
changed(integer change) { // something changed
if (change & CHANGED_LINK) { // and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me
llOwnerSay("if test");
//enter sitting state
state sitting;
}
else{
llOwnerSay("else");
state sitting;
}
}
}
}


state sitting{
state_entry(){
llOwnerSay("sitting");
}
//touching the prim should mean the avatar wants off
touch_start(integer total_number){
//unsit the avatar
llUnSit(llGetOwner());
llDie();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum