Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

taking controls on sit

Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
10-22-2007 19:07
Okay so I want to make something take my controls when it's sat on. But for some reason, this won't respond. What's wrong?
From: someone

integer desired_controls;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
llSitTarget(<0,0,1>,ZERO_ROTATION);
llRequestPermissions(llGetOwner(),PERMISSION_TAKE_CONTROLS);
}
changed(integer change) {
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == llGetOwner())
{
llTakeControls(desired_controls, TRUE, TRUE);
}
}
}
run_time_permissions(integer perms)
{
desired_controls =
CONTROL_FWD |
CONTROL_BACK |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT |
CONTROL_UP |
CONTROL_DOWN;


}
control(key id, integer down, integer new)
{
integer pressed = down & new;
integer held = down & ~new;
integer released = ~down & new;

if (pressed & CONTROL_UP)
llOwnerSay("Moved up";);
if (held & CONTROL_FWD)
llOwnerSay("Moved Fwd";);

}
}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
10-22-2007 20:54
Ok, well, think about what what you're saying, you said you want the object to ask permission when someone sits on your object. You're asking permission on state entry, and when you say yes, it triggers the runtime permissions event, therefore, the changed event doesnt execute until you sit. I think this is how what you're trying to do should be scripted, but for whatever reason, when I've test it, it doesnt ask permission when you sit the object. I put in some debug lines at one point, and when you sit, it triggers the changed event, the change & CHANGED_LINK is true (it falls thru to the next level), and the (llAvatarOnSitTarget() == llGetOwner()) is true as well (if falls thru to the llRequestPermissions. It does NOT ask permission, but it does then trigger the runtime_permissions event. I dont know why it's not working. Logically it is working, it's just not droping down the dialog to ask permission to take controls... Anyone?



integer desired_controls;

default
{
on_rez(integer sp)
{
llResetScript();
}

state_entry()
{
llSitTarget(<0,0,1>,ZERO_ROTATION);
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == llGetOwner())
{
llRequestPermissions (llGetOwner(),PERMISSION_TAKE_CONTROLS);
}
}
}

run_time_permissions(integer perms)
{
desired_controls =
CONTROL_FWD |
CONTROL_BACK |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT |
CONTROL_UP |
CONTROL_DOWN;
if (perms & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(desired_controls, TRUE, TRUE);
}


}
control(key id, integer down, integer new)
{
integer pressed = down & new;
integer held = down & ~new;
integer released = ~down & new;

if (pressed & CONTROL_UP)
llOwnerSay("Moved up";);
if (held & CONTROL_FWD)
llOwnerSay("Moved Fwd";);

}
}


Also, tried to look up your profile to IM you, but you dont appear in the search people? What's up with that?
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
10-22-2007 23:15
Certain permissions are granted automatically when you attach an object or sit on it.

Keyboard controls are among those permissions.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
10-23-2007 03:36
From: Squirrel Wood
Certain permissions are granted automatically when you attach an object or sit on it.

Keyboard controls are among those permissions.


Ok, but then why wasnt the keys working when I press them, my view moves, and the keypress are not detected by the script.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-23-2007 06:41
From: Johan Laurasia
Ok, but then why wasnt the keys working when I press them, my view moves, and the keypress are not detected by the script.
Yeah, that view moving is a clue. As far as I can tell, somehow llTakeControls seems to defer to the controls automatically assumed for cam rotation, etc., when the avatar sits on a prim. In the example, if one tests for CONTROL_LEFT and _RIGHT instead of _UP and _FWD, the events get through. Or, if you take the controls before the avatar sits, the controls all get through, even if you take them again upon sitting. It *might* be possible to get around this with a scripted cam or maybe the prim cam settings (llSetCameraAtOffset and -EyeOffset), but haven't tested that. Maybe somebody else has a better explanation--otherwise I think there's a bug (or undocumented "feature";) here.