Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Please Help With This Sit Question

BioMolecular Chemistry
Registered User
Join date: 16 Apr 2008
Posts: 24
05-26-2008 10:22
Hi I'm trying to ajust a typical non-physical vehicle script so that I can select the sit postion from a dialogue menu and having a bit of difficulty. I'm getting this error (Bionic: Script trying to take controls from owner but PERMISSION_TAKE_CONTROLS permission not set!) and the sit position won't change when i select different distances. Can anyone suggest a fix please. Here is the script I'm using...

// Non-Physical Flying Vehicle
// A.K.A: How to exploit tricks in LSL to get your way
//
// (your way being: up to 254 prims on a vehicle, in this case)
// Author: Jesrad Seraph
// Modify and redistribute freely, as long as your permit free modification and redistribution

string menuText = "Select your sit distance:";
string WALKANIM = "fly";
string IDLEANIM = "hover";
string UPANIM = "hover_up";
string DOWNANIM = "hover_down";

integer hidden_face = 5;

float max_fwd = 3.0; // max speed in m per quarter of a second
integer max_rot = 12; // max turning speed in degrees per quarter of a second

integer chan = -333;
integer channel = -333;
integer down;
integer change;

float fwd_accel = 0.0625; // forward/back acceleration
float up_accel = 0.0625; // vertical acceleration
float left_accel = 0.015625; // strafing acceleration
float rot_accel = 0.0625; // turning acceleration

float inertia = 0.5; // movement slowdown rate
float moment = 0.25; // turning slowdown rate

// internal stuff, don't modify
vector velocity;
float rotacity;
vector veloff = <0.5, 0.5, 0.5>;
integer timeout;

integer controls;
key pilot;

stop()
{
vector aim;
llReleaseControls();
llResetOtherScript("turn";);
llResetOtherScript("turn1";);
llResetOtherScript("turn2";);
llResetOtherScript("turn3";);
llResetOtherScript("rota";);
llResetOtherScript("rota1";);
llResetOtherScript("rota2";);
llResetOtherScript("rota3";);
llResetOtherScript("move";);
llResetOtherScript("move1";);
llResetOtherScript("move2";);
llResetOtherScript("move3";);
timeout = 0;
llSetTimerEvent(0.0);
pilot = NULL_KEY;
velocity = ZERO_VECTOR;
rotacity = 0.0;
llSetColor(velocity + veloff, hidden_face);
llSetAlpha(rotacity + 0.5, hidden_face);
aim = llRot2Euler(llGetRot());
aim.x = 0.0;
aim.y = 0.0;
llSetRot(llEuler2Rot(aim));
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation(IDLEANIM);
llStopAnimation(WALKANIM);
llStopAnimation(DOWNANIM);
llStopAnimation(UPANIM);
}
}

default
{
state_entry()
{
//controls = CONTROL_FWD|CONTROL_BACK|CONTROL_UP|CONTROL_DOWN|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT;
//stop();
//llSitTarget(<0.0, 0.0, -2.0>, ZERO_ROTATION);
//llSetCameraAtOffset(<0.0, 0.0, 0.0>;);
//llSetCameraEyeOffset(<-0.75, 0.0, -0.0>;);
llDialog(llGetOwner(), menuText, ["0m", "10m", "300m"], channel);
}

on_rez(integer param)
{
llResetScript();
}

// touch_start(integer c)
// {
// if (llDetectedKey(0) != llGetOwner()) return;
// else
// {
//
//}
// }

listen(integer channel, string name, key id, string message)
{
if (message == "0m";)
{
if ( llGetOwnerKey(id) == llGetOwner() )
{
controls = CONTROL_FWD|CONTROL_BACK|CONTROL_UP|CONTROL_DOWN|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT;
stop();
llSitTarget(<0.0, 0.0, -2.0>, ZERO_ROTATION);
llSetCameraAtOffset(<0.0, 0.0, 0.0>;);
llSetCameraEyeOffset(<-0.75, 0.0, -0.0>;);
}
}
if (message == "10m";)
{
if ( llGetOwnerKey(id) == llGetOwner() )
{
controls = CONTROL_FWD|CONTROL_BACK|CONTROL_UP|CONTROL_DOWN|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT;
stop();
llSitTarget(<0.0, 0.0, -10.0>, ZERO_ROTATION);
llSetCameraAtOffset(<0.0, 0.0, 0.0>;);
llSetCameraEyeOffset(<-0.75, 0.0, -0.0>;);
}
}
if (message == "300m";)
{
if ( llGetOwnerKey(id) == llGetOwner() )
{
controls = CONTROL_FWD|CONTROL_BACK|CONTROL_UP|CONTROL_DOWN|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT;
stop();
llSitTarget(<0.0, 0.0, -300.0>, ZERO_ROTATION);
llSetCameraAtOffset(<0.0, 0.0, 0.0>;);
llSetCameraEyeOffset(<-0.75, 0.0, -0.0>;);
}
}
}

run_time_permissions(integer p)
{
if (p & PERMISSION_TAKE_CONTROLS)
{
llResetOtherScript("turn";);
llResetOtherScript("turn1";);
llResetOtherScript("turn2";);
llResetOtherScript("turn3";);
pilot = llGetPermissionsKey();
llTakeControls(controls, TRUE, FALSE);
velocity = ZERO_VECTOR;
rotacity = 0.0;
llSetColor(velocity + veloff, hidden_face);
llSetAlpha(rotacity + 0.5, hidden_face);
llMessageLinked(LINK_THIS, 0, "piloted", pilot);
llStopAnimation("sit";);
llStartAnimation(IDLEANIM);
} else if (llGetPermissions() & PERMISSION_TAKE_CONTROLS == FALSE)
{
stop();
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if(agent)
{
if(agent != llGetOwner())
{
llUnSit(agent);
} else
{
llSetAlpha(0, ALL_SIDES);
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}
} else
{
llSetAlpha(1, ALL_SIDES);
if (pilot == llGetOwner())
{
stop();
}
}
}
}

control(key id, integer level, integer edge)
{
down = level;
change = edge;

if(down & (CONTROL_FWD|CONTROL_BACK)) {
llStartAnimation(WALKANIM);
llStopAnimation(UPANIM);
llStopAnimation(IDLEANIM);
llStopAnimation(DOWNANIM);
} else if(down & (CONTROL_UP)) {
llStartAnimation(UPANIM);
llStopAnimation(WALKANIM);
llStopAnimation(IDLEANIM);
llStopAnimation(DOWNANIM);
} else if (down & CONTROL_DOWN)
{
llStartAnimation(DOWNANIM);
llStopAnimation(WALKANIM);
llStopAnimation(UPANIM);
llStopAnimation(IDLEANIM);
} else
{
llStartAnimation(IDLEANIM);
llStopAnimation(WALKANIM);
llStopAnimation(UPANIM);
llStopAnimation(DOWNANIM);
}

if (down & controls)
{
if (timeout == 0)
{
llMessageLinked(LINK_THIS, max_rot, "nonphy", (key)((string)max_fwd));
llSetTimerEvent(0.05);
}
timeout = 12;
}
}

timer()
{
if (--timeout == 0)
{
llResetOtherScript("move";);
llResetOtherScript("move1";);
llResetOtherScript("move2";);
llResetOtherScript("move3";);
llResetOtherScript("rota";);
llResetOtherScript("rota1";);
llResetOtherScript("rota2";);
llResetOtherScript("rota3";);
llSetTimerEvent(0.0);
return;
}

if (down & CONTROL_FWD)
{
if (velocity.x < 0.0) velocity.x = 0.0;
velocity.x += fwd_accel;
if (velocity.x > 0.5 ) velocity.x = 0.5;
} else if (down & CONTROL_BACK)
{
if (velocity.x > 0.0) velocity.x = 0.0;
velocity.x -= fwd_accel;
if (velocity.x < -0.5 ) velocity.x = -0.5;
} else {
velocity.x *= inertia;
}

if (down & CONTROL_UP)
{
if (velocity.z < 0.0) velocity.z = 0.0;
velocity.z += up_accel;
if (velocity.z > 0.5 ) velocity.z = 0.5;
} else if (down & CONTROL_DOWN)
{
if (velocity.z > 0.0) velocity.z = 0.0;
velocity.z -= up_accel;
if (velocity.z < -0.5 ) velocity.z = -0.5;
} else {
velocity.z *= inertia;
}

if (down & CONTROL_LEFT)
{
if (velocity.y < 0.0) velocity.y = 0.0;
velocity.y += left_accel;
if (velocity.y > 0.5 ) velocity.y = 0.5;
} else if (down & CONTROL_RIGHT)
{
if (velocity.y > 0.0) velocity.y = 0.0;
velocity.y -= left_accel;
if (velocity.y < -0.5 ) velocity.y = -0.5;
} else {
velocity.y *= inertia;
}

if (down & CONTROL_ROT_LEFT)
{
if (rotacity < 0.0) rotacity = 0.0;
rotacity += rot_accel;
if (rotacity > 0.5 ) rotacity = 0.5;
} else if (down & CONTROL_ROT_RIGHT)
{
if (rotacity > 0.0) rotacity = 0.0;
rotacity -= rot_accel;
if (rotacity < -0.5 ) rotacity = -0.5;
} else {
rotacity *= moment;
}

llSetColor(velocity * llGetRot() + veloff, hidden_face);
llSetAlpha(rotacity + 0.5, hidden_face);
}
}
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
05-26-2008 10:42
llSitTarget cant change if you are siting on it, what you need to do is move the seat prim itself if the seat is in the main prim change it to a new prim and try llSetPos()
BioMolecular Chemistry
Registered User
Join date: 16 Apr 2008
Posts: 24
Thanks but I want to set the position first
05-26-2008 10:52
Thanks Mrc but the dialogue menu comes up after the object is rezzed. I want to be able to select the sit distance before I sit on the object??? Anyone else got any suggestions on how to make it work please??? Thanks
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
05-27-2008 00:01
I don't see an llListen() on your dialog channel anywhere. Maybe the problem is that the llSitTarget() is never getting called because there are no listen events.
BioMolecular Chemistry
Registered User
Join date: 16 Apr 2008
Posts: 24
Thanks BamBam
05-27-2008 02:07
Thanks mate you were right on the money - put in the llListen and it's all good now...Thanks a lot mate :)