Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help With Non Physical vehicle script....

Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-27-2006 20:08
Hi there, I'm trying to use Jesrad Seraph's non physical vehicle script in a flying craft. Can it be edited to add pitch and banking and rolling to the vehicle with this script? And if so how and where would I edit it in??



This is the main script....
CODE

// 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

integer hidden_face = 5;

float max_fwd = 2.0; // max speed in m per quarter of a second
integer max_rot = 4; // max turning speed in degrees per quarter of a second
float hover_height = 0.25; // prefered minimum height above ground

integer down;
integer change;

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

float inertia = 0.75; // movement slowdown rate
float moment = 0.5; // 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));
}

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.25, 0.0, 0.4>, ZERO_ROTATION);
llSetCameraAtOffset(<1.0, 0.0, 0.0>);
llSetCameraEyeOffset(<3.0, 0.0, 0.0>);
}

on_rez(integer param)
{
llResetScript();
}

touch_start(integer c)
{
if (llDetectedKey(0) != llGetOwner()) return;
if (pilot == llGetOwner())
{
stop();
} else
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}
}

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);
} else if (llGetPermissions() & PERMISSION_TAKE_CONTROLS == FALSE)
{
stop();
}
}

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

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;
if (llGetPos() * <0,0,1> < llGround(ZERO_VECTOR) + max_fwd * velocity.z + hover_height)
velocity.z = 0.0;
} else {
velocity.z *= inertia;
if (llGetPos() * <0,0,1> < llGround(ZERO_VECTOR) + max_fwd * velocity.z + hover_height)
velocity.z = 0.0;
}

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);
}
}
Lallander Parvenu
Registered User
Join date: 21 Apr 2005
Posts: 45
02-27-2006 20:25
Not sure if it will help, but nab the latest version. Unless I'm going mad, which staring at the LSL wiki might well be doing to me :P, it has a mouselook function. Haven't had a chance to play around with it myself, but I've heard its kinda fun.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
02-27-2006 22:11
Pitching is already in there, but in mouselook mode only.

The reason the scripts only do one axis rotation (yaw) right now, besides mouselook steering, is that I can only transmit a vector and a float from the main script to the movement/turn scripts right now, and the vector is used for movement.

BUT

You can change it so it uses the root prim's description instead of alpha of a hidden face, to pass a rotation instead of just a float. That allows your main script to calculate the rotation you want, and smoothly have the turn scripts apply it.

I'll make those changes in the next days. Expect the roll to be tied to yaw in the same way it is on SL planes.
_____________________
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.
Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-28-2006 16:10
Thats awesome I'll be looking for the update....and Thank You for an awesome script :)