hey all.
how would i go about making a "flight path" script.
a vehicle going from A -> B via points C,D & E and carrying multiple passengers.
These forums are CLOSED. Please visit the new forums HERE
flight path? |
|
Tabris Daxter
Snake oil Salesman
Join date: 22 Feb 2009
Posts: 61
|
10-16-2009 15:39
hey all.
how would i go about making a "flight path" script. a vehicle going from A -> B via points C,D & E and carrying multiple passengers. _____________________
DANCE WITH KIRBY
(^'-')^ (^'-')> (>'-')> < ![]() ![]() |
Carbon Philter
Registered User
Join date: 4 Apr 2008
Posts: 165
|
10-16-2009 15:57
If you check on XStreet there's a freebie Nashville Cat bulldozer which contains a script created by Barney Boomslang which is reusable as long as you comply with his GPL Licence terms.
It uses a waypoint set-up and should do what you want. |
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
|
10-18-2009 06:45
If your application is big enough you can code-in consistent Flight Level rules (http://en.wikipedia.org/wiki/Flight_plan) such as "In the U.S., eastbound (heading 0-179 degrees) IFR flights must use "odd" flight levels in 2000 foot increments starting at FL190 (i.e., FL190, FL210, FL230, etc.); Westbound (heading 180-359 degrees) flights must use "even" flight levels in 2000 foot increments starting at FL180 (i.e., FL180, FL200, FL220, etc.)."
Just for fun you can even write a sim-wide 'Air Traffic Controller' that directs and clears vehicles to certain heights and bearings. Many options are available ![]() |
Tabris Daxter
Snake oil Salesman
Join date: 22 Feb 2009
Posts: 61
|
Clarification
10-20-2009 18:49
i tried out the "CAT" script however it doesn't meet the requirements of my build as it requires STATIC REGION co-ordinates.
what i'm looking for (and is probably impossible) is a series of prims Not linked to act as a "guideway" so START -> A -> B -> C and so on until -> End. and these prims can be put in any location any order and create a path. i have seen something like this done with an auto-parking/docking system. _____________________
DANCE WITH KIRBY
(^'-')^ (^'-')> (>'-')> < ![]() ![]() |
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
|
10-21-2009 03:05
(I wonder what I was drinking when I wrote my last post here?)
First, there should be no problem with finding where the 'guideway' prims in a sim are because they can announce themselves when rezzed or moved with llRegionSay(). For less chat-traffic you could use llShout()/llSay() and keep each prim within range of it's neighbours, in which case the 'bus' or whatever will be able to hear the 'next stop' location once it gets to the one it's currently aiming for. IF you want a strict-order route and can give each stop-prim a unique name: In stop prims: ---------------- vector MyPos = <-1.0, 0.0, 0.0>; // Where I was last time, to see if a new announcement is required. Initially this is an 'invalid' position so the prim will announce itself as soon as it's rezzed. AnnouncePos(){ if (MyPos != llGetPos()){ MyPos = llGetPos(); llRegionSay(-4127, (string) MyPos);} } default{ on_rez(integer StartParam){ AnnouncePos(); llSetTimerEvent(10.0);} timer(){ AnnouncePos();} } In vehicle ----------- integer Counter; list Route = ["Stop A", "Stop C", "Stop D", "Stop E", "Stop B"]; // Or whatever, you might like to put this in a notecard or the description or somewhere easy to change without having to edit the script. list Positions = []; integer NextStop = 0; DoStop(){ llSetTimerEvent(0.0); // Do whatever it is you do at a stop-point if (++NextStop == llGetListLength(Route)) // Do whatever you do once the route is completed - reverse it, I suppose? else llSetTimerEvent(1.0); } default{ on_rez(integer StartParam){ llOwnerSay("Please rez the stop prims now. Waiting for position information." ![]() for (Counter = 0; Counter < llGetListLength(Route); ++Counter) Positions += [<-1.0, 0.0, 0.0>]; llListen((-4127, "", NULL_KEY, "" ![]() listen(integer ChannelIn, string FromName, key FromID, string Message){ // Check here that it's your object or whatever other security you implement Counter = llListFindList(Route, [FromName]); if (Counter > -1){ if (llList2Vector(Positions, Counter) == <-1.0, 0.0, 0.0> ![]() ++NextStop; Positions = llListReplaceList(Positions, [(vector) Message], Counter, Counter); if (NextStop == llGetListLength(Route)) state EnRoute;} } } state EnRoute{ state_entry(){ llOwnerSay("All stop positions received, EnRoute now" ![]() NextStop = 0; llListen((-4127, "", NULL_KEY, "" ![]() llSetTimerEvent(1.0); // Jerky movement, this is just an example!} listen(integer ChannelIn, string FromName, key FromID, string Message){ // Check here that it's your object or whatever other security you implement Counter = llListFindList(Route, [FromName]); if (Counter > -1) Positions = llListReplaceList(Positions, [(vector) Message], Counter, Counter);} timer(){ if (llGetPos() == llList2Vector(Positions, NextStop)) DoStop(); else // llSetPos() or whatever to get closer to the destination} } The trouble I think you might have is in shortest-path analysis - the classic travelling salesman problem of trying to work out a sensible route. If the 'stops' are in arbitrary positions and liable to move but you're following them in a strict order (a -> b -> c -> d, wherever they are) your vehicle could be crossing backwards and forwards across this sim when it may be more sensible to go a -> c -> b ->d or something. There are several algorithms and heuristics for path-optimisation but I'll spare us both the pain of going into them here. Is this more helpful than my last post? |
Lear Cale
wordy bugger
![]() Join date: 22 Aug 2007
Posts: 3,569
|
10-21-2009 11:18
Using Indeterminate Schism's method, to avoid having to run a 'shortest path first' algorithm, set the path, put the "waypoint number" in the message for each waypoint object. A simple way would be to use the object description or a suffix on the object name, so that the same script could be used for each waypoint object.
Indeterminate, next time please include the indentation when you post code. While we can't ever see the indentation in your post, we can if we use the QUOTE button. I hate trying to read unindented code. As a result, I didn't review this code. |