Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

swivel script?

Nimue Jewell
Unabashedly Leggy
Join date: 20 Mar 2007
Posts: 1,745
06-12-2007 11:15
Hi folks.

I have a question and it may be a dumb one, if so I'm sorry.

I have a customer that would like swiveling barstools (I make furniture) but I don't have a script for that. Is there a free open version of a script like that out there, or do i need to have one custom written for me?

Thanks so much.
_____________________

Prim Pincher: Low Prim Furniture for Home, Garden, & Skybox
http://slurl.com/secondlife/Nimue%20Isle/173/155/27
Hesius Heron
Registered User
Join date: 21 May 2007
Posts: 11
06-12-2007 11:27
Swivel and raise/lower? Or just constantly (and pointlessly) rotate?
Nimue Jewell
Unabashedly Leggy
Join date: 20 Mar 2007
Posts: 1,745
06-12-2007 11:43
LOL. Pointless rotation, now that is a feature!

I think that the idea is that the avi and chair actually rotate with the camera controls creating the effect to others that you and the chair are rotating.
_____________________

Prim Pincher: Low Prim Furniture for Home, Garden, & Skybox
http://slurl.com/secondlife/Nimue%20Isle/173/155/27
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-12-2007 13:08
From: Nimue Jewell
I think that the idea is that the avi and chair actually rotate with the camera controls creating the effect to others that you and the chair are rotating.


Wow, those will be some barstools. Seems like they'd get PERMISSION_TRACK_CAMERA from the sitter, but I can't convince myself we'd know what they were looking at, in order to know how to rotate the seat. We could know the cam position and rotation, which defines a vector in space, but they could be looking at any point on that vector. (we should be so lucky that the vector intersects the x,y of the seat's axis of rotation)
Nimue Jewell
Unabashedly Leggy
Join date: 20 Mar 2007
Posts: 1,745
06-12-2007 13:32
Yeah they are pretty cool. I found two versions in world. One at a little shop, the other at a big place selling the full perm script for way more than my customer (or I) want to pay.

Thanks for the help. :)
_____________________

Prim Pincher: Low Prim Furniture for Home, Garden, & Skybox
http://slurl.com/secondlife/Nimue%20Isle/173/155/27
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-12-2007 17:05
Are they adament about following the camera? I would probably tend to make their arrow keys move the stool but allow them normal camera operation incase they didnt' want to spin around all the time.

The gist of what I'd do is as follows, probably took more time to explain it here than do it hehe:

a) initiate all of this when they sit down using a couple of functions:
changed( integer change ) <-- event triggered when you sit on it, or anything changes
and check if(llAvatarOnSitTarget() != NULL_KEY) <-- is somebody sitting on it?
see:
http://rpgstats.com/wiki/index.php?title=LibrarySimpleHoverTextRemovalOnSit

b) take control of the CONTROL_LEFT|CONTROL_RIGHT controls and tell them to go into mouselook when they want to rotate (or shift-D, shift-A). That way they could still camera around while in a fixed position if they wanted to. This uses the library function LlTakeControls(); Which is a little wierd but not too bad, any free vehicle script does it, as do many others that do things much like you are trying to do. The gist of it is, make a permission request:
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);

then actually take control in a special event that you will get:
run_time_permissions(integer perms)
{
integer desired_controls = CONTROL_LEFT | CONTROL_RIGHT;

if (perms & PERMISSION_TAKE_CONTROLS) {
llTakeControls(desired_controls, TRUE, FALSE);
}
}

Then, handle those controls whenever they move their arrows in mouselook, or with shift-A or shift-D, in another special event you will get:
control(key id, integer held, integer change)
{
if (held & CONTROL_LEFT)
{
llOwnerSay("left";)
}
else if(held & CONTROL_RIGHT)
{
llOwnerSay("right";)
}
}


c) use those control overrides (they would get a popup when they sit down asking for permission for the stool to animate their avatar, like in a car etc) and rotate the chair about the correct axis (not always Z, depending how the chair was built). Rotating the chair is done very similar to any free door script opens a door, using llSetRot() function.

see the following example (rotations are a bit tricky):
vector degrees = <0, 0, 5>; //5 degrees around the z-axis, in Euler form
vector delta = degrees *= DEG_TO_RAD; //convert to radians rotation
rotation current_rot = llGetRot(); //current rotation
rotation delta = llEuler2Rot(delta); //change in rotation to apply
rot = delta * rot; //new rotation, after change
llSetRot(rot); //do it
//note, use <0,0,-5> to go the other direction.
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
06-13-2007 02:44
I created a swivel chair once which used the camera, but someone pointed out that they might not want others to see where they were looking at... So I changed it to use the arrow keys.

Lyn
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-13-2007 03:08
I'm curious if the swivel chairs that Nimue found in-world request cam perms, or take controls--either of which seem a bit, uh, "unexpected" of a barstool. Originally I thought the avatar could be wearing some attachment that already took controls for some incompatible purpose--although it's hard to imagine just what use it could make of rotation controls for a seated avatar.
Jake Trenchard
Registered User
Join date: 31 May 2007
Posts: 104
06-13-2007 11:03
The chairs that come with the 'VGA Poker Table' that almost all poker rooms use have a take-controls swivel feature. They take-control of left and right and put your camera view in first person perspective when you first sit in the chair (but you can adjust the camera after that.) They release controls when you stand up so you can go back to walking.

I don't know why it would be unexpected for a chair to take controls.... any sit action will -normally- take controls anyway, inasmuch as that makes it so you don't move around anymore with the arrow keys while you're seated. Just, normally, those keys don't do anything at all while you're seated. So, swivel by keys is extremely intuitive. Swivel by look would be more surprising.
Dytska Vieria
+/- .00004™
Join date: 13 Dec 2006
Posts: 768
06-13-2007 11:11
In the debug client, under Character, there is option to "Show Look At" or something like that. It is upgrade Wednesday, so I can't check. Anyway, if enabled, a type of crosshair is displayed for which the avi has mouse pointed.

Now, if there were also a ll script function that has vector of this look at feature, then the swivel script could use that information to rotate on z-axis to the look at location. The arrow keys would not be needed at all or could be optional.

Just a thought.
_____________________
+/- 0.00004