Change font size
It is currently Tue Jul 17, 2018 11:33 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: Boat Script
PostPosted: Tue Dec 21, 2010 11:51 pm 
Furious Typer

Joined: Wed Feb 17, 2010 9:17 pm
Posts: 94
Location: Florida
I have two questions about the problem I see with boat scripts, or vehicles in general.

Is there any creative way to make a boat "bump into land" rather than travel up onto it?

Is there any way to write a script that would stop a vehicle from trying to cross a region boundry? Something that would sense you are nearing a boundry and stop the vehicle?


Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Mon Dec 27, 2010 9:41 am 

Joined: Mon Dec 27, 2010 9:36 am
Posts: 24
// Very simple vehicle script, mod for OpenSim & ODE & VEHICLE code
// By Kitto Flora September 2009

// modified by Hiro Protagonist for basic aquatic motorcraft
// September 2009

integer Private = 1; // Change to 1 to prevent others riding.

vector Sitpos = <0.35,0,0.35>;
vector SitrotV = <0,-20,0>;
rotation Sitrot;
integer tt;
key oldagent;
key agent;
float forward_power = 8; //Power used to go forward (1 to 30)
float reverse_power = -3; //Power ued to go reverse (-1 to -30)
float turning_ratio = 1.0; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)
integer scount;
integer Speed;
integer Run;

string sit_message = "Man the Helm"; //Sit message
string not_owner_message = "You are not the owner of this vehicle, buy a copy for 0$ and have your own to test in this sim. It will not work in other Open Sim Regions."; //Not owner message

setVehicle()
{
//boat
llSetVehicleType(VEHICLE_TYPE_BOAT);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 2.0, 1000.0>);
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <0.1, 0.1, 0.1>);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.250);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.250);

}
Init()
{
Sound(0);
llSetBuoyancy(1);
llSetStatus(STATUS_PHYSICS, FALSE);
vector here = llGetPos();
float h = llWater(<0,0,0>) + 0.22;
vector rotv = llRot2Euler(llGetRot());
rotation rot = llEuler2Rot(<0,0,rotv.z>);
llSetPos(<here.x, here.y,h>);
llSetRot(rot);
Sitrot = llEuler2Rot(DEG_TO_RAD * SitrotV);
llSetVehicleType(VEHICLE_TYPE_NONE);
llMessageLinked(LINK_ALL_OTHERS, 0, "S", NULL_KEY); // wheels stop
llMessageLinked(LINK_ALL_OTHERS, 0, "WC", NULL_KEY); // wheels straight
Run = 0;
}

SetMaterial()
{
llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_WOOD]);
// llMessageLinked(LINK_ALL_OTHERS, 0, "SetMat", NULL_KEY); // Tell daughter pims on ground to be glass
}

Sound(integer n)
{
integer oldn;
if(n != oldn)
{
oldn = n;
if(n == 2)
{
// llLoopSound("RUNNING",1);
}
else if(n == 1)
{
// llLoopSound("IDLE",1);
}
else
{
// llStopSound();
}
}
}

default
{
state_entry()
{
Init();
llSetSitText(sit_message);
// forward-back,left-right,updown
llSitTarget(Sitpos, Sitrot);
// llStopSound();
}

on_rez(integer rn){
llResetScript();
}

changed(integer change)
{
if ((change & CHANGED_LINK) == CHANGED_LINK)
{
agent = llAvatarOnSitTarget();
if (agent != NULL_KEY)
{
if( (agent != llGetOwner()) && (Private == 1) )
{
llSay(0, not_owner_message);
llUnSit(agent);
// not functional llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);
}
else
{
//llTriggerSound("car_start",1);
// llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DRIVING", NULL_KEY);
oldagent = agent;
setVehicle();
SetMaterial();
llSleep(.4);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(.1);
Run = 1;
//Sensor is to make a crude Timer as TimerEvent fails on vehicles
llSensor("Non-Entity",NULL_KEY,PASSIVE,1.0, PI_BY_TWO);

llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
Sound(1);
}
}
else
{
Init();
llSleep(.4);
llReleaseControls();
llMessageLinked(LINK_ALL_OTHERS, 0, "S", NULL_KEY);
Run = 0;
llStopSound();
}
}
}

touch_start(integer tn){
}

run_time_permissions(integer perm)
{
if (perm)
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT |
CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
}

control(key id, integer level, integer edge)
{
integer reverse=1;
vector angular_motor;

//get current speed
vector vel = llGetVel();
float speed = llVecMag(vel);

//car controls
if(level & CONTROL_FWD)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 2.0, 1000.0>);
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power,0,0>);
reverse=1;
// NewWheelrot = "F";
Speed = 20;
}
if(level & CONTROL_BACK)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 2.0, 1000.0>);
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <reverse_power,0,0>);
reverse = -1;
// NewWheelrot = "R";
Speed = 10;
}

if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
{
angular_motor.z -= speed / turning_ratio * reverse;
// NewWheeldir = "WR";
// turncount = 10;
}

if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
{
angular_motor.z += speed / turning_ratio * reverse;
// NewWheeldir = "WL";
// turncount = 10;
}

llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
// if(turncount > 0)
// {
// turncount--;
// }
// if(turncount == 1)
// {
// NewWheeldir = "WC";
// }
// if(Wheeldir != NewWheeldir){
// Wheeldir = NewWheeldir;
// llMessageLinked(LINK_ALL_OTHERS, 0, Wheeldir, NULL_KEY);
// }
// if(Wheelrot != NewWheelrot){
// Wheelrot = NewWheelrot;
// llMessageLinked(LINK_ALL_OTHERS, 0, Wheelrot, NULL_KEY);
// }
} //end control

//Sensor is to make a crude Timer as TimerEvent fails on vehicles
no_sensor()
{
if(scount < 1000)
{
scount++;
}
else
{
scount = 0;
// This happens about once per second
if(Speed > 0) Speed--;

if(Speed > 2) Sound(2);

if(Speed == 1) {
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1.0, 2.0, 1000.0>);
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);
// llMessageLinked(LINK_ALL_OTHERS, 0, "S", NULL_KEY);
// Sound(1);
// Wheelrot = "S";
}

}

if(Run == 1)
llSensor("Non-Entity",NULL_KEY,PASSIVE,1.0, PI_BY_TWO);
}

} //end default


Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Mon Dec 27, 2010 9:56 am 

Joined: Mon Dec 27, 2010 9:36 am
Posts: 24
я не понимаю по английски........


Attachments:
File comment: он плывет...
Snapshot_291.jpg
Snapshot_291.jpg [ 111.89 KiB | Viewed 9209 times ]
Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Mon Dec 27, 2010 5:24 pm 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
что это нормально достаточно легко перевести. :) славное фото


Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Tue Dec 28, 2010 4:45 am 

Joined: Mon Dec 27, 2010 9:36 am
Posts: 24
thank you ))) спасибо...


Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Sat Apr 30, 2011 10:53 am 

Joined: Mon Dec 27, 2010 9:36 am
Posts: 24
.......еще один......


Attachments:
Snapshot_a530a.jpg
Snapshot_a530a.jpg [ 60.83 KiB | Viewed 8856 times ]
Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Tue May 03, 2011 1:33 pm 
Furious Typer
User avatar

Joined: Thu Aug 12, 2010 10:10 am
Posts: 56
Location: USA-Knoxville, TN
How do you add a Passanger to this? If we just add a sit prim or a ball sit the driver can't move when he gets off but the passanger can.


Top
 Profile  
 
 Post subject: Re: Boat Script
PostPosted: Thu May 05, 2011 11:59 am 

Joined: Mon Dec 27, 2010 9:36 am
Posts: 24
Shelann Morane {L_WROTE}:
How do you add a Passanger to this? If we just add a sit prim or a ball sit the driver can't move when he gets off but the passanger can.


можно конечно посадить двух человек, но надо ли - проблемы со скриптами (.........


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net