Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

scripting problem

XShade Foley
Registered User
Join date: 11 Feb 2006
Posts: 12
05-06-2006 00:03
the script below i mad to remote controll a vechial put i need it to work with physics on but it wont can any one tell me why it wont workw ith physics
CODE

key pilot = NULL_KEY;
string pilot_name = "";
integer controls_taken = FALSE;

set_pilot(key id, string name)
{
pilot = id;
pilot_name = name;
llRequestPermissions(id, PERMISSION_TAKE_CONTROLS);
}

release_controls()
{
if (controls_taken) {
pilot = NULL_KEY;
controls_taken = FALSE;
llReleaseControls();
}
}

move_by(vector offset)
{
llSetPos(llGetPos() + offset*llGetRot());
}

rotate_by(vector angular_offset)
{
llSetRot(llEuler2Rot(llRot2Euler(llGetRot()) + angular_offset * DEG_TO_RAD));
}

default
{
state_entry() {
llListen(1, "", NULL_KEY, "");
}


listen(integer channel, string name, key id, string message) {
if (message == "remote") set_pilot(llGetOwner(), llDetectedName(0));

}

control(key name, integer level, integer edge)
{
if (level & CONTROL_FWD) {
move_by(<0,.5,0>);
}
if (level & CONTROL_BACK) {
move_by(<0,-.5,0>);
}
if (level & CONTROL_LEFT || level & CONTROL_ROT_LEFT) {
rotate_by(<0,0,5>);
}
if (level & CONTROL_RIGHT || level & CONTROL_ROT_RIGHT) {
rotate_by(<0,0,-5>);
}
if (level & CONTROL_UP) {
move_by(<0,0,.5>);
}
if (level & CONTROL_DOWN) {
move_by(<0,0,-.5>);
}
}

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

Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
05-06-2006 04:31
I'm pretty sure that llSetPos is specifically for changing the position of non-physical objects.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-06-2006 10:03
Yeah, use llForce or llMoveToTarget for physical movement
XShade Foley
Registered User
Join date: 11 Feb 2006
Posts: 12
05-06-2006 10:33
that helped but now i cant get the rotation to work
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
05-06-2006 10:37
You'll want to peruse the wiki, specifically all the stuff on dynamics. The library calls you'll be most interested in are under kinetics, all that's physical.
_____________________