Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stop spinning...please

Zeta Eizenstark
Registered User
Join date: 20 Aug 2008
Posts: 79
11-09-2008 16:31
Ok, maybe I'm, like, oversimplifying this code but I don't know. I'm trying to make a prym, when touched, to tell another prym to start spinning and when touched again, to stop spinning. Now it does start to spin, but won't stop. HELP!

Here is the first prym
CODE

integer i = 0;
default
{
touch_start(integer total_number)
{
if(i==0)
{
llSay(-6,"start");
i=1;
}
if(i==1)
{
llSay(-6,"stop");
i=0;
}
}
}
CODE


Here is the spinny thing
CODE

integer listen_handle;
default
{
state_entry()
{
listen_handle = llListen(-6,"","Recorder","");
}

listen(integer channel, string s, key k, string msg)
{
while( msg == "start")
{
llTargetOmega(<1,0,0>,1,3);
}
while( msg == "stop")
{
llTargetOmega(<0,0,0>,0,0); <-Didn't know what else to do
}
}
}
CODE
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-09-2008 17:01
hmm, i'm having a similar issue with target omega, it stops, but strangely. click it once to start the rotation, click it again to stop it, for some reason it starts to spin again at the starting point and then snaps back and stops

From: someone

integer on = 1;

default {
state_entry()
{
llTargetOmega(<0,0,0>,0,0);
}
touch_start(integer n) {
if (on)
{
llTargetOmega(<0,0,1>,1,0.01);
}
else
{
llResetScript();
}
on = !on;
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-09-2008 17:03
actually, looking at yours, you might want to change while to if and else if. and in the touch script, have you tried it on channel 0 to make sure it's actually saying stop?
Lennard Lopez
Registered User
Join date: 9 Oct 2007
Posts: 52
11-09-2008 22:18
Zeta change the while loop because:

while( msg == "start";)
{
llTargetOmega(<1,0,0>,1,3);
}

msg equals "start" so this loop never ends anymore. There is no checking for a new msg.

Change it in:
listen(integer channel, string s, key k, string msg)
{
if( msg == "start";) llTargetOmega(<1,0,0>,1,3);
else if ( msg == "stop";) llTargetOmega(<0,0,0>,0,0);
}
Lennard Lopez
Registered User
Join date: 9 Oct 2007
Posts: 52
11-09-2008 22:35
Hello Ruthven.

llTargetOmega is a clientside rotation. On the server the prim doesn't rotate and every client sees a different rotation. Why resetting this script? That surely wil cause strange behavior. Do you need the state_entry? Not for this rotation. Using TRUE and FALSE makes the script more readable.

CODE

integer on = FALSE;
default {
touch_start(integer n) {
if (on) llTargetOmega(<0,0,0>,0,0); //if on is true switch rotation off
else llTargetOmega(<0,0,1>,1,0.01); //else switch it on
on=!on; } }
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-09-2008 22:44
actually i had it that way before, and it was simply stopping in place on my screen until i selected it. somehow resetting the script resets the rotation that i see. worked for for something that i had also changing position. but dealing with targetomega only is doing that odd bounce
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Barrington John
Yorkshire guy
Join date: 17 Nov 2007
Posts: 119
11-09-2008 23:14
Also the llListen() call has "Recorder" in the ID portion. If it's the name of the sending object, it should be the second parameter, not the third.

So this:

CODE
listen_handle = llListen(-6,"","Recorder","");

becomes this:

CODE
listen_handle = llListen(-6, "Recorder", NULL_KEY, "");
Zeta Eizenstark
Registered User
Join date: 20 Aug 2008
Posts: 79
11-11-2008 16:31
Thanks, everyone for your help, it is............WORKING!!!!!! YEAH!!!!! thank you.