Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with swing script

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
10-19-2008 20:55
I get free swing script by Eloise Pasteur and wanted to mod it for allowing remote commands. Actually script with my mod works well but with a little problem. When I send stop command, it doesn't park properly (I mean it doesn't turn back to its default rotation) . Original script parks well. Can someone please help me?

From: someone

string xCommand = "cswing";
string yCommand = "cstop";
integer chan = 9;
integer swing=FALSE;
float time=0.4;
integer steps=12;
integer swingDegrees = 45;

integer i=1;
float swingRad;
vector normal;

rotation Inverse(rotation r)
{
r.x = -r.x;
r.y = -r.y;
r.z = -r.z;
return r;
}
rotation GetParentRot()
{
return Inverse(llGetLocalRot())*llGetRot();
}
SetLocalRot(rotation x)
{
llSetRot(x*Inverse(GetParentRot()));
}

default
{
state_entry()
{
normal = llRot2Euler(llGetRot());
swingRad=DEG_TO_RAD*swingDegrees;
llSetTouchText("Swing";);
llListen(chan,"",NULL_KEY,"";);
}
listen(integer channel, string name, key id, string msg)
{
if (msg == yCommand)

{ normal=llRot2Euler(llGetRot());
llSetTimerEvent(0.0);
}
if (msg== xCommand)
{
swing=TRUE;
llSetTimerEvent(time);
}
}
timer()
{
float stepOffset=(float)i/steps*TWO_PI;
if(i>steps) i=1;
if(swing==FALSE && (i==steps || i==steps/2))
{
llSetTimerEvent(0.0);
SetLocalRot(llEuler2Rot(<normal.x, normal.y, normal.z + swingRad*llSin(stepOffset)>;));
} else
{
SetLocalRot(llEuler2Rot(<normal.x, normal.y, normal.z + swingRad*llSin(stepOffset)>;));
i++;
}
}
moving_end()
{
normal=llRot2Euler(llGetRot());
}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
10-20-2008 00:13
In the listen event, change the first if (stop) to this:
CODE


if (msg == yCommand)
{
swing = FALSE;
}



That's all.
Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
10-20-2008 08:14
ahh stupid me :) thanks a lot.