Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation Script Help, Please :)

Suzi Palmer
Registered User
Join date: 30 Dec 2006
Posts: 5
10-03-2007 09:08
I've done a couple of scripting classes and scripting communication classes but I can't figure out how to do this.

I want to make a script that will rotate an object (got this bit, yes I know its the easy bit) but I want to be able to turn it on and off with verbal commands. I've checked through my scripts and have some with channel and listen commands but can't figure out how to link them.

Any help much appreciated. Thanks.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
10-03-2007 13:18
In your state_entry, use llListen to listen on a particular channel (usually not 0!)

Then, in the listen() event, process what you hear . . .

if (message == "rotate";)
{
do stuff that makes it rotate;
}
else if (message == "stop";)
{
stop rotating;
}

You might also want to throw in some llToLower() and llStringTrim() and such to handle the cases where people type in a little differently than you expect.

Hope that helps . . .
IM me in-game if you have more questions . . .
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-03-2007 14:43
After you finish with it Suzi, why don't you throw it up here and let us take a look. We all might be able to give some pointers and also make sure the script is sim freindly. Also read carefully the section on Listens in the wiki and make them as tight as possible. Welcome to the world of scripting:-)
_____________________
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
Suzi Palmer
Registered User
Join date: 30 Dec 2006
Posts: 5
10-04-2007 13:39
OK, I got it doing what I was after (had to hack apart about 3 other scripts to figure it out). Please let me know any comments. Thanks Baron Hauptmann, yours was the bit I couldn't work out :)


default
{
state_entry()
{
llListen(1, "",llGetOwner(), "";);
}
listen(integer channel, string name, key id, string message) {

if (message == "rotate";)
{
llTargetOmega(<0,0,2>,1,1);
}
else if (message == "stop";)
{
llResetScript();
}


}


}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
10-04-2007 13:45
Does that 'stop' command really work? I thought that target omega was an object property (ie, you have to tell it to stop).

Either way.. I'd just do another llTargetOmega in the listen under "stop" instead of resetting the script, unless you have a reason to reset it.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Suzi Palmer
Registered User
Join date: 30 Dec 2006
Posts: 5
10-04-2007 13:53
The "Stop" is just what I say in chat, it activates the reset. I used the rest command because I hoped it would rest the object back to the original start position but it only stops the rotation.

EDIT: It does reset the objects, sweet :)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-04-2007 15:26
Nice job! To save on sim resources thou, there is no need to check this:

From: someone

if (llGetOwnerKey(id)==llGetOwner()) {

You are using a nice, tight listen and you have already declared that it will only be triggered if the owner is speaking.
_____________________
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
Suzi Palmer
Registered User
Join date: 30 Dec 2006
Posts: 5
10-04-2007 15:37
ah cool, script updated.

Thank You :)