2 Questions on my non-physical vehicle
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-11-2005 23:32
So I have this 4 seater non-physical (i.e. it moves around with llSetPos()), with all the seats hidden and with sittargets. When the owner gets on, it takes their controls and moves around fine, but when a second person joins them, it automatically releases the controls. Do I have to take the new persons controls too? And if I do, if the new person gets off and I want to release their controls, will an llReleaseControls() let go of all avatars controls, or just the person who got off? Second Question: For turning, I'm using this- if ( level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT) ) { llSetRot(llGetRot() - <0,0,.5,0>); llSetCameraEyeOffset(<-4, 0, 5>); llSetCameraAtOffset(<2, 0, 1>); } if ( level & (CONTROL_LEFT|CONTROL_ROT_LEFT) ) { llSetRot(llGetRot() + <0,0,.5,0>); llSetCameraEyeOffset(<-4, 0, 5>); llSetCameraAtOffset(<2, 0, 1>); } The problem is that once it gets to 180 degrees of a turn, it can't turn anymore, and you have to turn around all the way in the opposite direction to face the way your trying to go. Is there any way of fixing this? Thanks for the help.
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
08-12-2005 02:05
Wow, first thing first: rotations are stored in quaternion form, not euler form, in SL. If you add quaternions together like in your control code, strange things are bound to happen. The correct way to apply a quaternion rotation in LSL is by multiplication, so what you really want to use is: if ( level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT) ) { llSetRot(llGetRot() * llEuler2Rot(<0,0,-0.5>));
} if ( level & (CONTROL_LEFT|CONTROL_ROT_LEFT) ) { llSetRot(llGetRot() * llEuler2Rot(<0,0,.5>));
}
And put llSetCameraEyeOffset(<-4, 0, 5>  ; llSetCameraAtOffset(<2, 0, 1>  ; in your state_entry() event, since you only need to call it once. As for the TakeControls() / ReleaseControls() issue, I'll need the code you are using in your changed() and runtime_permission() events in order to help.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-12-2005 12:02
Okay, thanks for the rotation help, here's the code for the llTakeControls(). Here's script #1, in its state entry is an llSitTarget() changed(integer change) { if (change & CHANGED_LINK) { if ( llAvatarOnSitTarget() != NULL_KEY ) { if ( llAvatarOnSitTarget() != owner ) { llWhisper(0, "You are not the leader, wait until they get on to join."); llUnSit(llAvatarOnSitTarget()); // unsit avatar } if ( llAvatarOnSitTarget() == owner ) { llSetTimerEvent(0); leadon = TRUE; llMessageLinked(LINK_SET,Clead,"leaderon",""); } } if ( llAvatarOnSitTarget() == NULL_KEY && leadon == TRUE ) { llMessageLinked(LINK_SET,Clead,"leaderoff",""); } } Here's Script #2, a separate script that got the information that the leader was on by llMessageLinked() above if ( num == Clead ) { if ( str == "leaderon" ) { integer prm = llGetPermissions(); if ( (prm & PERMISSION_TAKE_CONTROLS) != PERMISSION_TAKE_CONTROLS ) { llRequestPermissions(owner,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION); } } } then later in the same script run_time_permissions(integer perm) { llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_DOWN | CONTROL_UP, TRUE, FALSE); } Now, this works fine until another person gets onto another one of the predefined (by llSitTarget) seats. Then it automatically releases controls. In that script, it does not take controls of them because they are a passenger, so I didn't think it needed it. the only perms it takes are trigger_animation. so whatsup? Note: I already tried setting the pass_on in llTakeControls() as TRUE, with no effect.
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
08-13-2005 01:32
Let's see if I understand this right:
1) owner sits: the main script detects it in changed() and sends the correct link message 2) the controls script requests permissions and takes controls of the owner 3) someone else sits on the vehicle too, this calls the changed() event again 4) the main script re-detects the owner (still sitting on its sittarget) but apparently gets a NULL_KEY or the other AV's key from the llAvatarOnSitTarget() call ?
Is there a "Permission not set" error when that happens ?
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-13-2005 13:49
There is no error message. If a prim is link number 1, and another is link 2, if someon site on link 2, is the changed() event activated on number 1 as well?
I guess it could be returning a null key when someone else gets on, but I'm not sure, I'll run some more tests when I get on.
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 14:04
From: Douglas Callahan There is no error message. If a prim is link number 1, and another is link 2, if someon site on link 2, is the changed() event activated on number 1 as well? I guess it could be returning a null key when someone else gets on, but I'm not sure, I'll run some more tests when I get on. The changed() event is for the whole object, so yes. What I do is track the last answer, as it were, so I can pare my decision tree to three possibilities: An av has attached to the sit target, the av has left the sit target, or some other change I don't need to be concerned with has happened. Global variable: key agentKey = NULL_KEY; changed(integer c) { key av = llAvatarOnSitTarget(); if ( av != NULL_KEY && agentKey == NULL_KEY ) // Probably a fresh sit { agentKey = av; // Record who's sitting here //Do other sit stuff here // NOTE this is where you check to see if the avatar is who you want sitting here, and eject them if they're not. } else if ( av == NULL_KEY && agentKey != NULL_KEY ) // Probably an agent stood up { // Do stand-up things here agentKey = NULL_KEY; } // else, something changed we just dont care about. } Hope that helps some. 
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
08-13-2005 16:08
This is interesting. Just making sure I understand how this works. So changed() is sent to the whole object, but llAvatarOnSitTarget() is just for that prim, and will return whoever's sitting on that prim?
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 16:28
From: Ziggy Puff This is interesting. Just making sure I understand how this works. So changed() is sent to the whole object, but llAvatarOnSitTarget() is just for that prim, and will return whoever's sitting on that prim? Basically correct. The change being monitored is CHANGED_LINK, which is by nature about the whole object. Once you know a link change has happened, then you become concerned with finding out information that's prim-specific - namely if the sit target is in use. Wiki stuff for: changed() llAvatarOnSitTarget()
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
08-14-2005 01:10
Thanks 
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
08-15-2005 15:31
Okay, sorry for the delay, I'm sure the owner key is not returning NULL when someone else gets on, any other ideas? I can show you inworld if you IM me.
_____________________
Other than that, Mrs. Lincoln, how was the play?
|