normalized perms on all files, to avoid relying on any stored executable bits in...
[feisty_meow.git] / huffware / huffotronic_scripts / jaunt_wik_rez_v86.3.txt
1 
2 // huffware script: jaunt wik rez, by fred huffhines,  released under GPL license.
3 //
4 // this is a jaunter (teleporter) script with some useful and uncommon features.
5 // it can work around certain types of complicated land permissions on neighboring land
6 // that might otherwise lead to blocked jaunts.
7 // the usage of "jaunt" for teleportation is inspired by the alfred bester novel, "the stars
8 // my destination".  if you like science fiction and have not read this book, it is highly
9 // recommended.
10 // parts of this script are based on "Teleporter Script v 3.0 by Asira Sakai", from
11 // the LSL wiki.
12 //
13 // use jaunt wik rez by placing a notecard in the inventory of your jaunter object.  the notecard
14 // should start with "#jaunt" on the first line and then should have alternating lines of
15 // (1) jaunt target (as a vector) and (2) readable target name, for example:
16 //      #jaunt
17 //      <23, 18, 92>
18 //      gracy square
19 //      <182, 32, 56>
20 //      tourmaline palace
21 //      <23, 18, 92>|<118, 19, 108>|<120, 33, 57>
22 //      unblocked pathway, hurrah
23 // note the last destination; the script also supports a list of intermediate destinations.
24 // this feature can enable one to route a teleport around blocked lands by using waypoints
25 // that are still accessible.  but since the current version of the script automatically
26 // finds routes for most destinations, this is not needed very frequently.
27 //
28 // this script is licensed by the GPL v3 which is documented at: http://www.gnu.org/licenses/gpl.html
29 // do not use it in objects without fully realizing you are implicitly accepting that license.
30 //
31
32 //////////////
33
34 integer DEBUGGING = FALSE;
35     // make true to print diagnostic logging.
36
37 // configurable options (set in notecard):
38
39 integer SHOW_TEXT = TRUE;
40     // if true, then the jaunter will show a text label for the destination.
41     // this can be configured from the notecard with ":show_text=0" to turn off,
42     // or 1 to turn on.
43 integer ADD_NAME = FALSE;
44     // if this is true, then the text shown will include the object's name.
45
46 string TEXT_COLOR = "<0.3, 0.9, 0.7>";
47     // set float text color to a nice color.
48 ///hmmm: doesn't seem to be in the notecard yet!
49
50 //////////////
51
52 // the jaunter button pushing API.
53 //////////////
54 integer BUTTON_PUSHER_HUFFWARE_ID = 10029;
55     // a unique ID within the huffware system for this script.
56 //////////////
57 string BUTTON_PUSHED_ALERT = "#btnp";
58     // this event is generated when the button is pushed.  the number parameter will be
59     // the huffware id plus the reply distance.  the id parameter in the link message will
60     // contain the name of the button that was 
61 string JAUNT_NEXT_BUTTON_NAME = "next";
62 string JAUNT_MENU_BUTTON_NAME = "menu";
63
64 //////////////
65     
66 // requires the jaunt config API.
67 //////////////
68 // do not redefine these constants.
69 integer JAUNT_CONFIGURATION_HUFFWARE_ID = 10022;
70     // the unique id within the huffware system for this script's commands.
71     // it's used in llMessageLinked as the num parameter.
72 string HUFFWARE_PARM_SEPARATOR = "{~~~}";
73     // this pattern is an uncommon thing to see in text, so we use it to separate
74     // our commands in link messages.
75 string HUFFWARE_ITEM_SEPARATOR = "{|||}";
76     // used to separate lists of items from each other when stored inside a parameter.
77     // this allows lists to be passed as single string parameters if needed.
78 integer REPLY_DISTANCE = 100008;  // offset added to service's huffware id in reply IDs.
79 //////////////
80 // commands available from the jaunt config library:
81 string LOAD_ALL_CONFIGURATIONS = "#rdcfg#";
82     // this starts the process of loading jaunt destinations from the notecards and
83     // landmarks that we find in the object.  the parms are: private channel
84     // and conveyance mode.
85 string JAUNT_CFG_DATA_EVENT = "#yodata#";
86     // this event is generated from this script back to the caller.  when we have some
87     // landmark data or configuration information, it's passed back in chunks.  the
88     // deluge of pieces will continue until the JAUNT_CFG_EOF event is passed.  the
89     // parameters include packed destination name and vector pairs (which form 2 elements
90     // in the list) and packed config variable definitions (where config items start
91     // with a colon, and the definition is only one element in the list).
92 string JAUNT_CFG_EOF = "#done#";
93     // sent after all valid configuration items that we could find were processed.
94 //
95 //////////////
96
97 // requires jaunting library API.
98 //////////////
99 // do not redefine these constants.
100 integer JAUNT_HUFFWARE_ID = 10008;
101     // the unique id within the huffware system for the jaunt script to
102     // accept commands on.  this is used in llMessageLinked as the num parameter.
103 //////////////
104 // commands available via the jaunting library:
105 string FULL_STOP_COMMAND = "#fullstop#";
106     // command used to bring object to a halt.
107 string JAUNT_LIST_COMMAND = "#jauntlist#";
108     // like regular jaunt, but expects a string in jaunt notecard format with vectors.
109     // the second parameter, if any, should be 1 for forwards traversal and 0 for backwards.
110 //
111 //////////////
112
113 // requires menutini API.
114 //////////////
115 // do not redefine these constants.
116 integer MENUTINI_HUFFWARE_ID = 10009;
117     // the unique id within the huffware system for the jaunt script to
118     // accept commands on.  this is used in llMessageLinked as the num parameter.
119 string SHOW_MENU_COMMAND = "#menu#";
120     // the command that tells menutini to show a menu defined by parameters
121     // that are passed along.  these must be: the menu name, the menu's title
122     // (which is really the info to show as content in the main box of the menu),
123     // the wrapped list of commands to show as menu buttons, the menu system
124     // channel's for listening, and the key to listen to.
125
126 // requires data cow library API.
127 //////////////
128 // do not redefine these constants.
129 integer DATA_COW_HUFFWARE_ID = 10017;
130     // the unique id within the huffware system for the jaunt script to
131     // accept commands on.  this is used in llMessageLinked as the num parameter.
132 //////////////
133 string RESET_LIST_COMMAND = "reset_L";
134     // flushes out the currently held list.  does not send a reply.
135 string ADD_ITEM_COMMAND = "add_I";
136     // adds items to the list.  this is a list of pairs of name/value, where the name is
137     // how the item will be looked up from the list, and the value is the contents to be stored.
138     // this command has no reply.
139 string GET_COW_LENGTH = "get_Lc";
140     // returns a single integer which is the length of the cow's list currently.
141 //string REMOVE_ITEM_COMMAND = "rm_I";
142     // accepts a list of names for items.  all the mentioned ones will be removed from the list.
143     // this command also has no reply.
144 //string GET_ITEM_COMMAND = "get_I";
145     // retrieves the item's contents for a given name.  first parm is the name.  if there
146     // are other parameters, then they are taken as other items to return also.
147     // the return data will be pairs of <name, entry> for each of the names in the request.
148     // if the data was not located, then the entry will be empty.
149 string TAGGED_GET_ITEM_COMMAND = "get_T";
150     // like get item, except the first parameter is an identifier that the caller wants to
151     // use to tag this request.  the other parameters are still taken as names.  the response
152     // will contain the tag as the first item, then the <name, entry> pairs that were found.
153
154 //////////////
155
156 // requires click action API...
157 //////////////
158 integer CHANGE_CLICK_ACTION_HUFFWARE_ID = 10024;
159     // a unique ID within the huffware system for this script.
160 // the API only supports the service number; there are no commands to pass in the "msg"
161 // parameter.  the id does accept a parameter, which is the type of click action to begin
162 // using for this prim.
163 //////////////
164
165 // the API for this library script to be used in other scripts.
166 //////////////
167 // do not redefine these constants.
168 integer JAUNT_REZOLATOR_HUFFWARE_ID = 10025;
169     // the unique id within the huffware system for this script's commands.
170     // it's used in llMessageLinked as the num parameter.
171 //////////////
172 // commands available from the library:
173 string RESET_REZOLATOR = "#reset";
174     // tells the script to stop any previous efforts to rez children.
175 string REZ_CHILD_NOW = "#rezkd#";
176     // requests this script to create a new child object.  this requires several
177     // parameters to succeed: 1) object to rez, 2) conveyance mode for the rezzed object
178     // to implement, 3) the chat channel to listen for and speak to new child on,
179     // 4) the destination name for where the child should go, 5) a count of the full
180     // set of known destinations, 6) the target where the jaunt should arrive at.
181 //////////////
182 // events generated by the library:
183 string REZOLATOR_EVENT_REZZED_CHILD = "#donekd";
184     // an event generated for a previous rez child request.  this lets the caller know that
185     // the child has been created and told what to do.  the single parameter is where the
186     // jaunter has been rezzed.
187 string REZOLATOR_EVENT_RECON_FINISHED = "#rzcnfn";
188     // an event generated when the recon process has concluded.  this includes parms:
189     // number of good destinations.
190 //
191 //////////////
192
193 // important constants used internally...  these should not be changed willy nilly.
194
195 ////////////// jaunt base API
196
197 // the following constants define how the script should behave (i.e., its conveyance mode).
198 // TWO_WAY_TRIP: the script jaunts using the current target vectors to get somewhere
199 //   and then takes the same pathway back, but in reverse order.
200 // AUTOREZ_JAUNTER: the script rezzes the first regular object in its inventory next to
201 //   the root telehub.  that object is loaded with the destination notecard and this script.
202 //   the rezzed object can then be used for the next few minutes to jaunt to the selected
203 //   destination.  the temporary object will use the ONE_WAY_TRIP mode.
204 // ONE_WAY_TRIP: the object containing this script will take the user to a particular
205 //   destination, but the object does not survive the trip.  it self-destructs after
206 //   reaching the destination.  this mode is used in conjunction with the AUTOREZ_JAUNTER
207 //   mode and should generally never be used on its own.
208 // RECONNAISSANCE_TRIP: a survey run to test out a particular path to get to a
209 //   destination.
210 integer TWO_WAY_TRIP = 1;
211 integer AUTOREZ_JAUNTER = 2;
212 integer ONE_WAY_TRIP = 3;
213 integer RECONNAISSANCE_TRIP = 4;
214
215 // values used to represent different stages of verification.
216 integer VERIFY_UNTESTED = -3;  // don't know destinations state yet.
217 integer VERIFY_SAFE = -4;  // the destination last tested safe.
218 integer VERIFY_UNSAFE_SO_FAR = -5;  // this cannot be done with simple jaunt.
219 integer VERIFY_UNSAFE_DECIDED = -6;  // this means the destination seems intractable.
220
221 integer MAXIMUM_PRIV_CHAN = 90000;
222     // the largest amount we will ever subtract from the tricky parms in order to
223     // tell the sub-jaunter which channel to listen on.
224
225 string VECTOR_SEPARATOR = "|";
226     // how we separate components of vectors from each other.
227 string DB_SEPARATOR = "``";  // separating items in lists.
228
229 ////////////// end jaunt base API
230
231 integer MAX_DEST_NAME = 24;  // the longest name that we store.
232
233 float NORMAL_TIMER_PERIOD = 1.0;  // our normal timer rate.
234
235 string RESET_COMMAND = "jreset";  // forget everything and start over.
236 string SHOW_COMMAND = "show";  // describe the known destinations.
237 string RECON_COMMAND = "recon";  // tells the jaunter to run reconnaissance on destinations.
238
239 float POSITION_CHECKING_INTERVAL = 0.11;
240     // how frequently the waiting for arrival state will check where we are.
241
242 integer MAXIMUM_SLACKNESS = 108;
243     // how many timer hits we'll allow before reverting to the default state.
244
245 integer FREE_MEM_REQUIRED = 1600;
246     // we need at least this much memory before adding new targets.
247
248 // somewhere between two and 10 minutes (default) will elapse before first recon testing.
249 float MIN_RECON_SNOOZE = 120;
250 float MAX_RECON_SNOOZE = 1200;
251
252 // the actions that can be held in the action queue.
253 integer AQ_SHOW_DEST_RECORD = 23;  // a record to be shown to the user.
254 integer AQ_FINISH_SHOW_DESTS = 24;  // last record in a jaunt destinations list.
255 integer AQ_CLICK_ACTION_REQUEST = 25;  // the response should set our click action.
256 integer AQ_SELECT_DESTINATION = 27;  // the user has chosen a different destination.
257 integer AQ_DONE_CONFIGURING = 28;  // the last step of the configuration process has finished.
258
259 string OUR_COW_TAG = "jwkrz_dc";  // unique id for this script to talk to the data cow with.
260
261 //////////////
262
263 // global variables.
264
265 integer private_chat_channel;  // where sub-jaunters communicate with root.
266 integer conveyance_mode;  /// = TWO_WAY_TRIP;
267     // default is a standard two way trip, there and back again.  note that the object
268     // will fail to return if any lands in between are blocking object entry.  those
269     // situations should use an auto-rez jaunter, which is specified by prefixing the
270     // target vectors with AR.
271 integer last_verification_state;  // the verification state of the last destination we asked for.
272 string last_pathway;  // similar, but the last pathway we heard.
273 integer current_target_index;  // the location in the list that we would currently jaunt to.
274
275 integer good_destinations;  // computed during the recon process.
276
277 // jaunter target configuration...
278 list global_names;  // the names for each destination.
279
280 // jaunt trip variables...
281 vector eventual_destination;  // where we're headed, if we're headed anywhere.
282 integer slackness_counter;  // snoozes had while waiting for destination.
283 list full_journey;  // the full pathway we expect to jaunt on.
284 integer jaunt_responses_awaited;  // number of pending jumps in progress.
285
286 // root jaunter variables...
287 integer child_needs_setup;
288     // true when a child has been rezzed and still needs to be filled with the script.
289
290 integer recon_started_yet = FALSE;
291     // true if we've finished running through the reconnaissance process yet.
292
293 //////////////
294
295 // makes our click action change to the type requested, and sends the request
296 // out to all our sub-prims also.
297 set_click_action(integer action)
298 {
299     llSetClickAction(action);
300     // secret message to other prims to change click action.
301     llMessageLinked(LINK_SET, CHANGE_CLICK_ACTION_HUFFWARE_ID, "", (string)action);
302 }
303
304 integer random_channel() { return -(integer)(llFrand(40000) + 20000); }
305
306 // show the list of options for someone who used the click-hold feature.
307 show_jaunt_menu(key last_toucher)
308 {
309     llMessageLinked(LINK_THIS, MENUTINI_HUFFWARE_ID, SHOW_MENU_COMMAND,
310         "jm" + HUFFWARE_PARM_SEPARATOR
311         + "Jaunt to..." + HUFFWARE_PARM_SEPARATOR
312         + wrap_item_list(global_names)
313         + HUFFWARE_PARM_SEPARATOR
314         + (string)random_channel() + HUFFWARE_PARM_SEPARATOR
315         + (string)last_toucher);
316 }
317
318 // respond to the user's choice.
319 react_to_menu(string which_choice)
320 {
321     integer indy;
322     // find the specified destination and select it.
323     indy = llListFindList(global_names, [which_choice]);
324     if (indy >= 0) {
325         current_target_index = indy;
326         select_destination(current_target_index);
327     }
328 }
329
330 // asks the jaunting library to take us to the target using a list of waypoints.
331 request_jaunt(list journey, integer forwards)
332 {
333     // ask for a jump.
334     jaunt_responses_awaited++;
335     llMessageLinked(LINK_THIS, JAUNT_HUFFWARE_ID, JAUNT_LIST_COMMAND,
336         wrap_item_list(journey) + HUFFWARE_PARM_SEPARATOR + (string)forwards);
337     // stops the jaunter in its tracks.
338     llMessageLinked(LINK_THIS, JAUNT_HUFFWARE_ID, FULL_STOP_COMMAND, ""); 
339 }
340
341 // this function returns TRUE if we are close enough to the "destination".
342 integer close_enough(vector destination)
343 {
344     float PROXIMITY_REQUIRED = 0.1;
345         // how close we must be to the target location to call it done.
346         // matches current jaunting library proximity.
347     return (llVecDist(llGetPos(), destination) <= PROXIMITY_REQUIRED);
348 }
349
350 // returns appropriate sit text for our current jaunt mode.
351 string sit_text()
352 {
353     if (conveyance_mode == AUTOREZ_JAUNTER) return "Rez Ride";
354     return "Jaunt";
355 }
356
357 // plops a new destination on the end of the lists.
358 add_destination(string name, string path, integer verif)
359 {
360 //    if (DEBUGGING) log_it("adding " + name + " with path " + path);
361     global_names += [ name ];
362     // send our new information to the data cow.  we store the information encoded as
363     // two separated items, where the first element is the destination and the second
364     // is the verification state.
365     string new_entry = wrap_item_list([path, verif]);
366     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, ADD_ITEM_COMMAND,
367         wrap_parameters([name, new_entry]));
368 }
369
370 // sets up the initial state, if this script has just started, or it
371 // cleans up the state, if the script was already running.
372 initialize_jaunter()
373 {
374     llSetTimerEvent(0.0);  // cancel any existing timers.
375
376     // reset all the important variables.
377     global_names = [];
378     current_target_index = 0;
379     good_destinations = 0;
380
381     llSitTarget(<0, 0, 0.1>, ZERO_ROTATION);
382         // set a rudimentary sit target or opensim won't give us our changed events.
383     // load up an arrival sound if any exist.
384     if (llGetInventoryNumber(INVENTORY_SOUND))
385         llPreloadSound(llGetInventoryName(INVENTORY_SOUND, 0));
386     // reset the parallel processing scripts since we've restarted.
387     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, RESET_LIST_COMMAND, "");
388     llMessageLinked(LINK_THIS, JAUNT_REZOLATOR_HUFFWARE_ID, RESET_REZOLATOR, "");
389     
390     // see if we can load our configuration from notecards and landmarks.
391     // we pick a private channel that fits in between our rez parm ranges.
392     private_chat_channel = (integer)randomize_within_range(-MAXIMUM_PRIV_CHAN, -1, FALSE);
393     // request that all the config get loaded up.
394     llMessageLinked(LINK_THIS, JAUNT_CONFIGURATION_HUFFWARE_ID, LOAD_ALL_CONFIGURATIONS,
395          wrap_parameters([private_chat_channel, conveyance_mode]));
396     // during a normal trip, we will make sure the notecard reading doesn't stall.
397     // the recon and one way jaunters don't need this; they're temporary.
398     // we allow this number of seconds before notecard reader is awol.
399     llSetTimerEvent(94);
400
401     conveyance_mode = TWO_WAY_TRIP;  // default init in opensim friendly way.
402
403     // set up some of the object properties...
404     string msg;
405     if (SHOW_TEXT) msg = "?...";
406     llSetText(msg, (vector)TEXT_COLOR, 1.0);  // initial floating text for jaunter.
407     llSetSitText(sit_text());  // change to the proper text for our mode.
408 }
409
410 init_normal_runtime()
411 {
412     child_needs_setup = FALSE;
413     // listen to the general public for commands.
414     llListen(0, "", NULL_KEY, "");
415     // set up a root jaunter.
416     recon_started_yet = FALSE;        
417     llSetTimerEvent(randomize_within_range(MIN_RECON_SNOOZE, MAX_RECON_SNOOZE, FALSE));
418 }
419
420 // signal that we are where we were going.
421 proclaim_arrival()
422 {
423     if (conveyance_mode == TWO_WAY_TRIP) {
424         // sing a little song, if there's a sound to use.
425         if (llGetInventoryNumber(INVENTORY_SOUND))
426             llTriggerSound(llGetInventoryName(INVENTORY_SOUND, 0), 1.0);
427     }
428 }
429
430 string verification_name(integer enumtype)
431 {
432     if (enumtype == VERIFY_SAFE) return "ok";
433     else if (enumtype == VERIFY_UNSAFE_SO_FAR) return "uhh";
434     else if (enumtype == VERIFY_UNSAFE_DECIDED) return "far";
435     // catch-all, including untested.
436     return "?";
437 }
438
439 // returns true if the slackness counter awaiting things has elapsed.
440 integer check_for_timeout()
441 {
442     if (slackness_counter++ > MAXIMUM_SLACKNESS) {
443         // go back to the main state.  we took too long.
444         log_it("timed out!");
445         llUnSit(llAvatarOnSitTarget());  // don't hang onto the avatar for this error.
446         llSetTimerEvent(0.0);
447         return TRUE;
448     }
449     return FALSE;
450 }
451
452 //////////////
453
454 // action queue for postponed activities.  the first field held in a list item here
455 // is an integer action code.  the format of the remaining parameters is up to the
456 // caller, and they can be used as the final parameters for when the queued action
457 // gets handled.
458 list action_queue;
459
460 // looks at the action code at the head of the queue without removing the action.
461 integer peek_action_code()
462 {
463     list fields = llParseString2List(llList2String(action_queue, 0), [HUFFWARE_PARM_SEPARATOR], []);
464     return extract_action_code(fields);
465 }
466
467 // extracts the action code from a retrieved list.
468 integer extract_action_code(list to_parse) { return llList2Integer(to_parse, 0); }
469
470 // removes the current head of the action queue and returns it.
471 list pop_action_record()
472 {
473     if (llGetListLength(action_queue) == 0) {
474 //        if (DEBUGGING) log_it("failure in action q: no entries.");
475         return [];
476     }
477     list top_action = llParseString2List(llList2String(action_queue, 0), [HUFFWARE_PARM_SEPARATOR], []);
478     action_queue = llDeleteSubList(action_queue, 0, 0);
479     jaunt_responses_awaited--;  // one less thing to wait for.
480     return top_action;
481 }
482
483 // adds a new action to the end of the action queue.
484 push_action_record(integer action, list added_parms)
485 {
486     action_queue += [ wrap_parameters([action] + added_parms) ];
487     jaunt_responses_awaited++;  // add one counter to our pending responses.
488 }
489
490 //////////////
491
492 string show_buffer;  // used by the destination list showing code below.
493
494 // requests a dump of all the jaunt destinations so we can show them to the user.
495 get_destination_records()
496 {
497     show_buffer = "[mem " + (string)llGetFreeMemory() + "]";  // set the first line in the output.
498     
499     integer indy;
500     for (indy = 0; indy < llGetListLength(global_names); indy++) {
501         string curr = llList2String(global_names, indy);
502         // ask for this destination record.
503         llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, TAGGED_GET_ITEM_COMMAND,
504             wrap_parameters([OUR_COW_TAG, curr]));
505         integer action = AQ_SHOW_DEST_RECORD;
506         if (indy == llGetListLength(global_names) - 1) {
507             // if it's the last item, make sure we signal that.
508             action = AQ_FINISH_SHOW_DESTS;
509         }
510         push_action_record(action, []);
511     }
512 }
513
514 // displays the list of destinations in normal chat that the data cow is handing us.
515 show_destination_record(string loc_name, string pathway, integer verif, integer action)
516 {
517     integer MAX_CHAT = 512;  // the largest we let the buffer get before saying it.
518     show_buffer += "   " + loc_name + " ("
519         + verification_name(verif) + ") ↣ " + pathway;
520     // if we're done, add a note about quality of targets.
521     if (action == AQ_FINISH_SHOW_DESTS) {
522         show_buffer += "\n  (" + (string)good_destinations + " safe & "
523             + (string)(llGetListLength(global_names) - good_destinations)
524             + " tough ones)";
525     }
526         
527     // if we're done or if the string gets too big, print and reset it.
528     if ( (action == AQ_FINISH_SHOW_DESTS) || (llStringLength(show_buffer) >= MAX_CHAT) ) {
529         llWhisper(0, show_buffer);
530         show_buffer = "";
531     }
532 }
533
534 // returns the value of a boolean variable definition.
535 integer parse_bool_def(string def)
536 { return !(llGetSubString(def, find_substring(def, "=") + 1, -1) == "0"); }
537
538 // processes a configuration option from the notecard.
539 handle_config_item(string item)
540 {
541     item = llGetSubString(item, 1, -1);  // chop the command signifier character.
542     if (is_prefix(item, "show_text")) {
543         // they are controlling whether to show the text label or not.
544         SHOW_TEXT = parse_bool_def(item);
545     } else if (is_prefix(item, "add_name")) {
546         ADD_NAME = parse_bool_def(item);
547     }
548 }
549
550 // processes items coming from the configuration library.
551 consume_configuration_items(string msg, string id)
552 {
553     list parms = llParseString2List(id, [HUFFWARE_PARM_SEPARATOR], []);
554     integer mem_okay = llGetFreeMemory() >= FREE_MEM_REQUIRED;  // false if we're low on memory.
555     if (!mem_okay) return;
556     integer indy;
557     for (indy = 0; indy < llGetListLength(parms); indy += 2) {
558         string name = llList2String(parms, indy);
559         if (is_prefix(name, ":")) {
560             handle_config_item(name);
561             indy--;  // skip back so we continue looking for destinations.
562         } else {
563             // this should be a normal pair of destination vector and name.
564             integer verif_state = VERIFY_UNTESTED;
565             // check if it's a wacky location.
566             string map_coord = llList2String(parms, indy + 1);
567             list chewed = chewed_destination(map_coord);
568             if (outside_of_sim((vector)llList2String(chewed, 0))) {
569                 if (DEBUGGING) log_it("ruled map_coor " + (string)map_coord + " out of sim.");
570                 // make sure we consider the tp location "unsafe", since we can't run in-sim
571                 // reconnaissance against it.  also, we must postpone marking it until
572                 // the destination is listed, given current implementation.
573                 verif_state = VERIFY_UNSAFE_DECIDED;
574             }
575             add_destination(name, llList2String(parms, indy + 1), verif_state);
576         }
577     }
578 }
579
580 // handles responses about our list coming back from the data cow.
581 integer answer_to_the_cow(string msg, string id, list parms)
582 {
583     string tag = llList2String(parms, 0);
584     if (tag != OUR_COW_TAG) return FALSE;  // was not for us.
585     parms = llDeleteSubList(parms, 0, 0);  // trim out the tag.
586     list action_record = pop_action_record();
587     integer actyo = extract_action_code(action_record);
588     list split = llParseString2List(llList2String(parms, 1), [HUFFWARE_ITEM_SEPARATOR], []);
589     if ( (actyo == AQ_SHOW_DEST_RECORD) || (actyo == AQ_FINISH_SHOW_DESTS) ) {
590         show_destination_record(llList2String(parms, 0), llList2String(split, 0),
591             llList2Integer(split, 1), actyo);
592     } else if (actyo == AQ_CLICK_ACTION_REQUEST) {
593         // make sure we're in the right mode for clicking based on how
594         // many destinations we have.  if there's only one, we might as
595         // well make this jaunter just go there.
596         // note: just discovered that we cannot set the click action if the jaunter
597         // is multiple prims.  that's totally fubar.  it means we cannot correctly
598         // set the jaunter main body to show 'sit' as the option, even when jaunting
599         // directly to the destination is possible.  freaking lindens.  maybe osgrid
600         // will fix this someday.
601         if (llGetListLength(global_names) == 1) {
602             if (llList2Integer(split, 1) != VERIFY_UNSAFE_DECIDED)
603                 set_click_action(CLICK_ACTION_SIT);
604             else
605                 // we have a non-local jaunter, so set up for map clicking.
606                 set_click_action(CLICK_ACTION_TOUCH);
607         } else set_click_action(CLICK_ACTION_TOUCH);
608     } else if (actyo == AQ_SELECT_DESTINATION) {
609         integer verif = llList2Integer(split, 1);
610         // we only switch conveyance mode if we have not been told to
611         // do the one-way trip or recon.
612         if (verif == VERIFY_SAFE) conveyance_mode = TWO_WAY_TRIP;
613         else conveyance_mode = AUTOREZ_JAUNTER;
614         llSetSitText(sit_text());  // change to the proper text for our mode.
615         full_journey = [ vector_chop(llGetPos()) ] + chewed_destination(llList2String(split, 0));
616         integer last_selecting_index = llList2Integer(action_record, 1);
617         string destname = llList2String(global_names, last_selecting_index);
618         llWhisper(0, "Next stop: " + destname);
619         text_label_for_destination(destname);
620         last_verification_state = verif;
621         last_pathway = llList2String(split, 0);
622     } else if (actyo == AQ_DONE_CONFIGURING) {
623         // done with notecard reading, but we still need reconnaissance.
624         // we'll do that in the normal runtime state.
625         return TRUE;        
626     }
627     return FALSE;  // unknown request or a fall-through.
628 }
629
630 // asks the data cow for our current set of configured destinations and their
631 // requisite click actions.
632 request_destinations()
633 {
634     push_action_record(AQ_CLICK_ACTION_REQUEST, []);
635     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, TAGGED_GET_ITEM_COMMAND,
636         wrap_parameters([OUR_COW_TAG, llList2String(global_names, 0)]));
637 }
638
639 // processes link messages received from support libraries.
640 integer handle_link_message(integer which, integer num, string msg, string id)
641 {
642     // is it an answer about our configuration?
643     if (num == JAUNT_CONFIGURATION_HUFFWARE_ID + REPLY_DISTANCE) {
644         if (msg == JAUNT_CFG_DATA_EVENT) {
645             // eat these configuration items we were given.
646             consume_configuration_items(msg, id);
647         } else if (msg == JAUNT_CFG_EOF) {
648             // we have finished up on the configuration.
649             completed_configuration();
650         }
651         return FALSE;
652     }
653     
654     // is it a jaunting library response?
655     if (num == JAUNT_HUFFWARE_ID + REPLY_DISTANCE) {
656         jaunt_responses_awaited--;  // one less response being awaited.
657         if (jaunt_responses_awaited < 0) {
658             if (DEBUGGING) log_it("error: j-rsp-awtd<0");
659             jaunt_responses_awaited = 0;
660         }
661         return FALSE;
662     }
663     
664     // is it an event from the rezolator script?
665     if (num == JAUNT_REZOLATOR_HUFFWARE_ID + REPLY_DISTANCE) {
666         list parms = llParseString2List(id, [HUFFWARE_PARM_SEPARATOR], []);
667         if (msg == REZOLATOR_EVENT_REZZED_CHILD) {
668             // we know the child is ready for us now.
669             child_needs_setup = FALSE;
670 //            if (DEBUGGING) log_it("setting journey to rez place " + vector_chop(llGetPos()));
671             full_journey = [ vector_chop(llGetPos()), llList2String(parms, 0) ];
672             if (DEBUGGING) log_it("heard kid is ready, helping.");
673             request_jaunt(full_journey, TRUE);
674             eventual_destination = (vector)llList2String(full_journey, llGetListLength(full_journey) - 1);
675             llSetTimerEvent(POSITION_CHECKING_INTERVAL);
676         } else if (msg == REZOLATOR_EVENT_RECON_FINISHED) {
677             good_destinations = llList2Integer(parms, 0);
678             if (DEBUGGING) log_it("recon finished, total=" + llGetListLength(global_names) + " good=" + good_destinations);
679             request_destinations();
680             select_destination(current_target_index);
681         }
682         return FALSE;
683     }
684
685     // is this a menu response from the user?
686     if (num == MENUTINI_HUFFWARE_ID + REPLY_DISTANCE) {
687         // all we care about in our parms is the choice made.
688         react_to_menu(llList2String(llParseString2List(id, [HUFFWARE_PARM_SEPARATOR], []), 1));
689         return FALSE;
690     }
691     // or maybe it's a piece of data from the data cow.
692     if (num == DATA_COW_HUFFWARE_ID + REPLY_DISTANCE) {
693         return answer_to_the_cow(msg, id, llParseString2List(id, [HUFFWARE_PARM_SEPARATOR], []));
694     }
695     // perhaps it's a click on a button.
696     if (num == BUTTON_PUSHER_HUFFWARE_ID + REPLY_DISTANCE) {
697         if (msg == BUTTON_PUSHED_ALERT) {
698             list parms = llParseString2List(id, [HUFFWARE_PARM_SEPARATOR], []);
699             if (llList2String(parms, 0) == JAUNT_NEXT_BUTTON_NAME) {
700                 select_next_destination();
701             } else if (llList2String(parms, 0) == JAUNT_MENU_BUTTON_NAME) {
702                 show_jaunt_menu(llList2String(parms, 1));
703             }
704         }
705     }
706
707     return FALSE;
708 }
709
710 // make some noise about getting configured right.
711 completed_configuration()
712 {
713     current_target_index = 0;  // set proper index.    
714     get_destination_records();
715
716     // set up the first destination.
717     select_destination(current_target_index);
718
719     // schedule the request asking how many destinations there are.
720     request_destinations();
721 /*    push_action_record(AQ_CLICK_ACTION_REQUEST, []);
722     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, TAGGED_GET_ITEM_COMMAND,
723         wrap_parameters([OUR_COW_TAG, llList2String(global_names, 0)]));*/
724
725     // add an item in the queue to actually begin jaunt services.
726     push_action_record(AQ_DONE_CONFIGURING, []);
727     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, TAGGED_GET_ITEM_COMMAND,
728             wrap_parameters([OUR_COW_TAG, llList2String(global_names, 0)]));
729 }
730
731 // process what we hear in open chat and on our special channels.
732 // this function should always return FALSE unless it's been given enough info
733 // to enter a new state, in which case it should return true.
734 integer listen_to_voices(integer channel, string name, key id, string message)
735 {
736     if (channel == 0) {
737         // provide common command handling.
738         if (message == SHOW_COMMAND) {
739             // anyone can use this command.
740             get_destination_records();
741             return FALSE;
742         }
743         // the rest of the commands only listen to the owner.
744         if (id != llGetOwner()) return FALSE;
745         if (message == RESET_COMMAND) llResetScript();
746         else if (message == RECON_COMMAND) {
747             // if they want a recon, we'll do it right away.
748             recon_started_yet = FALSE;
749             // we want to reset the rezolator's state, in case it had done this before.
750             llMessageLinked(LINK_THIS, JAUNT_REZOLATOR_HUFFWARE_ID, RESET_REZOLATOR, "");
751             llSetTimerEvent(0.4);
752         }
753         return FALSE;
754     }
755
756     return FALSE;  // we do not want to go to next state; stay in current one.
757 }
758
759 // shows our next target for jaunting above the object.
760 text_label_for_destination(string target)
761 {
762     string msg;
763     if (SHOW_TEXT) {
764         if (ADD_NAME) msg += llGetObjectName() + ":\n";
765         msg += "↣ " + target;
766     }
767     llSetText(msg, (vector)TEXT_COLOR, 1.0);
768 }
769
770 select_next_destination()
771 {
772     // picks the next place in the list for the destination, or wraps around.
773     current_target_index++;
774     if (current_target_index >= llGetListLength(global_names))
775         current_target_index = 0;
776     select_destination(current_target_index);
777 }
778         
779 touchy_feely()
780 {
781     // check the safety of the target and show the map if the conditions are right.
782     vector check_posn = (vector)llList2String(chewed_destination(last_pathway), 0);
783 ///    if (outside_of_sim(check_posn)) {
784     /////old && (llGetListLength(global_names) == 1) ) {
785         // bring up the map; maybe we can't get there from here.  definitely out of sim.
786         llMapDestination(llGetRegionName(), check_posn, ZERO_VECTOR);
787         proclaim_arrival();
788 ///    }
789 }
790
791 // if the string "to_chew" looks like an offset vector, we return the calculated position.
792 // otherwise we just convert the string to a list of vectors.
793 list chewed_destination(string dests)
794 {
795
796 //hmmm: document this!!!
797 //      as in, we support the offset format!
798
799     // look for our special start character for offsets.
800     if (is_prefix(dests, "o"))
801         return [ (vector)llDeleteSubString(dests, 0, find_substring(dests, "<") - 1) + llGetPos() ];
802
803 //        if (DEBUGGING) log_it("decided for normal jaunt instead.");        
804     // jaunt to list of absolute coordinates.
805     return llParseString2List(dests, [VECTOR_SEPARATOR], []);
806 }
807
808 // sets the current destination to the vector at "which_index".
809 select_destination(integer which_index)
810 {
811     push_action_record(AQ_SELECT_DESTINATION, [which_index]);
812     llMessageLinked(LINK_THIS, DATA_COW_HUFFWARE_ID, TAGGED_GET_ITEM_COMMAND,
813         wrap_parameters([OUR_COW_TAG, llList2String(global_names, which_index)]));
814 }
815
816 // processes the timer events from normal runtime.
817 handle_normal_runtime_timer()
818 {
819     if (!recon_started_yet) {
820         if (DEBUGGING) log_it("moving on to recon finally.");
821         llMessageLinked(LINK_THIS, JAUNT_REZOLATOR_HUFFWARE_ID, REZ_CHILD_NOW,
822             wrap_parameters( [llGetInventoryName(INVENTORY_OBJECT, 1),
823                 RECONNAISSANCE_TRIP, private_chat_channel,
824                 "n",  // don't care about a particular name.
825                 llGetListLength(global_names),
826                 "n"  // no particular path.
827                 ]));
828         recon_started_yet = TRUE;  // well, started really.                
829     }
830     llSetTimerEvent(0.0);  // stop coming here.
831 }
832
833 //////////////
834
835 //////////////
836 // from hufflets...
837
838 integer debug_num = 0;
839
840 // a debugging output method.  can be disabled entirely in one place.
841 log_it(string to_say)
842 {
843     debug_num++;
844     // tell this to the owner.    
845     llOwnerSay(llGetScriptName() + "[" + (string)debug_num + "] " + to_say);
846     // say this on open chat, but use an unusual channel.
847 //    llSay(108, (string)debug_num + "- " + to_say);
848 }
849
850 ///////////////
851
852 // returns TRUE if the value in "to_check" specifies a legal x or y value in a sim.
853 integer valid_sim_value(float to_check)
854 {
855     if (to_check < 0.0) return FALSE;
856     if (to_check >= 257.0) return FALSE;
857     return TRUE;
858 }
859
860 // returns TRUE if the "to_check" vector is a location outside of the current sim.
861 integer outside_of_sim(vector to_check)
862 {
863     return !valid_sim_value(to_check.x) || !valid_sim_value(to_check.y);
864 }
865
866 // returns text for a floating point number, but includes only
867 // two digits after the decimal point.
868 string float_chop(float to_show)
869 {
870     integer mant = llAbs(llRound(to_show * 100.0) / 100);
871     string neg_sign;
872     if (to_show < 0.0) neg_sign = "-";
873     string dec_s = (string)((llRound(to_show * 100.0) - mant * 100) / 100.0);
874     dec_s = llGetSubString(llGetSubString(dec_s, find_substring(dec_s, ".") + 1, -1), 0, 2);
875     // strip off all trailing zeros.
876     while (llGetSubString(dec_s, -1, -1) == "0")
877         dec_s = llDeleteSubString(dec_s, -1, -1);
878     string to_return = neg_sign + (string)mant;
879     if (llStringLength(dec_s)) to_return += "." + dec_s;
880     return to_return;
881 }
882
883 // returns a prettier form for vector text, with chopped floats.
884 string vector_chop(vector to_show)
885 {
886     return "<" + float_chop(to_show.x) + ","
887         + float_chop(to_show.y) + ","
888         + float_chop(to_show.z) + ">";
889 }
890
891 // joins a list of parameters using the parameter sentinel for the library.
892 string wrap_parameters(list to_flatten)
893 { return llDumpList2String(to_flatten, HUFFWARE_PARM_SEPARATOR); }
894 //
895 // joins a list of sub-items using the item sentinel for the library.
896 string wrap_item_list(list to_wrap)
897 { return llDumpList2String(to_wrap, HUFFWARE_ITEM_SEPARATOR); }
898
899 // returns a number at most "maximum" and at least "minimum".
900 // if "allow_negative" is TRUE, then the return may be positive or negative.
901 float randomize_within_range(float minimum, float maximum, integer allow_negative)
902 {
903     if (minimum > maximum) {
904         // flip the two if they are reversed.
905         float temp = minimum; minimum = maximum; maximum = temp;
906     }
907     float to_return = minimum + llFrand(maximum - minimum);
908     if (allow_negative) {
909         if (llFrand(1.0) < 0.5) to_return *= -1.0;
910     }
911     return to_return;
912 }
913
914 // returns the portion of the list between start and end, but only if they are
915 // valid compared with the list length.  an attempt to use negative start or
916 // end values also returns a blank list.
917 list chop_list(list to_chop, integer start, integer end)
918 {
919     integer last_len = llGetListLength(to_chop) - 1;
920     if ( (start < 0) || (end < 0) || (start > last_len) || (end > last_len) ) return [];
921     return llList2List(to_chop, start, end);
922 }
923
924 // returns the index of the first occurrence of "pattern" inside
925 // the "full_string".  if it is not found, then a negative number is returned.
926 integer find_substring(string full_string, string pattern)
927 {
928     string full_lower = llToLower(full_string);
929     return llSubStringIndex(full_lower, pattern);
930 }
931
932 // returns TRUE if the "prefix" string is the first part of "compare_with".
933 integer is_prefix(string compare_with, string prefix)
934 { return find_substring(compare_with, prefix) == 0; }
935
936 //////////////
937 // huffware script: auto-retire, by fred huffhines, version 2.8.
938 // distributed under BSD-like license.
939 //   !!  keep in mind that this code must be *copied* into another
940 //   !!  script that you wish to add auto-retirement capability to.
941 // when a script has auto_retire in it, it can be dropped into an
942 // object and the most recent version of the script will destroy
943 // all older versions.
944 //
945 // the version numbers are embedded into the script names themselves.
946 // the notation for versions uses a letter 'v', followed by two numbers
947 // in the form "major.minor".
948 // major and minor versions are implicitly considered as a floating point
949 // number that increases with each newer version of the script.  thus,
950 // "hazmap v0.1" might be the first script in the "hazmap" script continuum,
951 // and "hazmap v3.2" is a more recent version.
952 //
953 // example usage of the auto-retirement script:
954 //     default {
955 //         state_entry() {
956 //            auto_retire();  // make sure newest addition is only version of script.
957 //        }
958 //     }
959 // this script is partly based on the self-upgrading scripts from markov brodsky
960 // and jippen faddoul.
961 //////////////
962 auto_retire() {
963     string self = llGetScriptName();  // the name of this script.
964     list split = compute_basename_and_version(self);
965     if (llGetListLength(split) != 2) return;  // nothing to do for this script.
966     string basename = llList2String(split, 0);  // script name with no version attached.
967     string version_string = llList2String(split, 1);  // the version found.
968     integer posn;
969     // find any scripts that match the basename.  they are variants of this script.
970     for (posn = llGetInventoryNumber(INVENTORY_SCRIPT) - 1; posn >= 0; posn--) {
971         string curr_script = llGetInventoryName(INVENTORY_SCRIPT, posn);
972         if ( (curr_script != self) && (llSubStringIndex(curr_script, basename) == 0) ) {
973             // found a basic match at least.
974             list inv_split = compute_basename_and_version(curr_script);
975             if (llGetListLength(inv_split) == 2) {
976                 // see if this script is more ancient.
977                 string inv_version_string = llList2String(inv_split, 1);  // the version found.
978                 // must make sure that the retiring script is completely the identical basename;
979                 // just matching in the front doesn't make it a relative.
980                 if ( (llList2String(inv_split, 0) == basename)
981                     && ((float)inv_version_string < (float)version_string) ) {
982                     // remove script with same name from inventory that has inferior version.
983                     llRemoveInventory(curr_script);
984                 }
985             }
986         }
987     }
988 }
989 //
990 // separates the base script name and version number.  used by auto_retire.
991 list compute_basename_and_version(string to_chop_up)
992 {
993     // minimum script name is 2 characters plus a version.
994     integer space_v_posn;
995     // find the last useful space and 'v' combo.
996     for (space_v_posn = llStringLength(to_chop_up) - 3;
997         (space_v_posn >= 2) && (llGetSubString(to_chop_up, space_v_posn, space_v_posn + 1) != " v");
998         space_v_posn--) {
999         // look for space and v but do nothing else.
1000     }
1001     if (space_v_posn < 2) return [];  // no space found.
1002     // now we zoom through the stuff after our beloved v character and find any evil
1003     // space characters, which are most likely from SL having found a duplicate item
1004     // name and not so helpfully renamed it for us.
1005     integer indy;
1006     for (indy = llStringLength(to_chop_up) - 1; indy > space_v_posn; indy--) {
1007         if (llGetSubString(to_chop_up, indy, indy) == " ") {
1008             // found one; zap it.  since we're going backwards we don't need to
1009             // adjust the loop at all.
1010             to_chop_up = llDeleteSubString(to_chop_up, indy, indy);
1011         }
1012     }
1013     string full_suffix = llGetSubString(to_chop_up, space_v_posn, -1);
1014     // ditch the space character for our numerical check.
1015     string chop_suffix = llGetSubString(full_suffix, 1, llStringLength(full_suffix) - 1);
1016     // strip out a 'v' if there is one.
1017     if (llGetSubString(chop_suffix, 0, 0) == "v")
1018         chop_suffix = llGetSubString(chop_suffix, 1, llStringLength(chop_suffix) - 1);
1019     // if valid floating point number and greater than zero, that works for our version.
1020     string basename = to_chop_up;  // script name with no version attached.
1021     if ((float)chop_suffix > 0.0) {
1022         // this is a big success right here.
1023         basename = llGetSubString(to_chop_up, 0, -llStringLength(full_suffix) - 1);
1024         return [ basename, chop_suffix ];
1025     }
1026     // seems like we found nothing useful.
1027     return [];
1028 }
1029 //
1030 //////////////
1031
1032 //////////////
1033
1034 // default state scrounges for information in a notecard and looks for landmarks in
1035 // inventory to add as destinations.
1036 default
1037 {
1038     state_entry() { if (llSubStringIndex(llGetObjectName(),  "huffotronic") < 0) state real_default; }
1039     on_rez(integer parm) { state rerun; }
1040 }
1041 state rerun { state_entry() { state default; } }
1042
1043 state real_default
1044 {
1045     state_entry() {
1046         auto_retire();
1047         if (DEBUGGING) log_it("=> default, mem=" + (string)llGetFreeMemory());
1048         initialize_jaunter();
1049     }
1050
1051     timer() {
1052         // config loading timed out.
1053         log_it("config timeout; resetting.");
1054         llResetScript();
1055     }
1056     
1057     // process the response from the noteworthy library.
1058     link_message(integer which, integer num, string msg, key id) {
1059         if (handle_link_message(which, num, msg, id)) {
1060             state normal_runtime;
1061         }
1062     }
1063     
1064     on_rez(integer parm) { state default; }  // start-up from scratch.
1065 }
1066
1067 // the normal state is pretty calm; the jaunter just sits there waiting for
1068 // an avatar who needs it to do something.
1069 state normal_runtime
1070 {
1071     state_entry() {
1072         if (DEBUGGING) log_it("=> normal");
1073         init_normal_runtime();
1074     }
1075
1076     listen(integer channel, string name, key id, string message) {
1077         if (listen_to_voices(channel, name, id, message)) {
1078             // we're ready to take off now.
1079             state jaunting_now;
1080         }
1081     }
1082
1083     timer() { handle_normal_runtime_timer(); }
1084
1085     touch_end(integer total_number)
1086     {
1087         if (llDetectedLinkNumber(0) != llGetLinkNumber()) return;
1088         touchy_feely();
1089     }
1090
1091     changed(integer change) {
1092         // always react to a change by resetting the label, in hopes we'll see
1093         // the targeting arrow properly.
1094         string destname = llList2String(global_names, current_target_index);
1095         text_label_for_destination(destname);
1096         // now do our 'real' activities for changes.
1097         if (change & CHANGED_INVENTORY) {
1098             log_it("inventory changed; restarting.");
1099             llResetScript();
1100         }
1101         if (!(change & CHANGED_LINK)) return;  // don't care then.
1102         if (llAvatarOnSitTarget() == NULL_KEY) return;  // there is no one sitting now.
1103         state jaunting_now;  // sweet, we're off.
1104     }
1105         
1106     // process the response from the menu library.
1107     link_message(integer which, integer num, string msg, key id) {
1108         handle_link_message(which, num, msg, id);
1109     }
1110
1111     on_rez(integer parm) { state default; }  // start-up from scratch.
1112 }
1113
1114 // once someone is trying to jump to a target, this state processes the request.
1115 state jaunting_now
1116 {
1117     state_entry() {
1118         if (DEBUGGING) log_it("=> jauntnow, posn=" + vector_chop(llGetPos()));
1119         jaunt_responses_awaited = 0;  // nothing pending right now.
1120         slackness_counter = 0;
1121         if (conveyance_mode == AUTOREZ_JAUNTER) {
1122             // we're going to create a kid, so we will not change state until we hear from it.
1123             child_needs_setup = TRUE;
1124             // give the person a vehicle to ride to the unsafe locale.  we assume the
1125             // one way jaunter is the first inventory item.
1126             llMessageLinked(LINK_THIS, JAUNT_REZOLATOR_HUFFWARE_ID, REZ_CHILD_NOW,
1127                 wrap_parameters([llGetInventoryName(INVENTORY_OBJECT, 0),
1128                     ONE_WAY_TRIP, private_chat_channel,
1129                     llList2String(global_names, current_target_index),
1130                     llGetListLength(global_names),
1131                     llDumpList2String(full_journey, VECTOR_SEPARATOR) ]));
1132         } else {
1133 //            if (DEBUGGING) log_it("now going to first locat: " + (string)full_journey);
1134             // patch the journey list for our most current location.
1135             full_journey = [ vector_chop(llGetPos()) ] + llDeleteSubList(full_journey, 0, 0);
1136
1137             // most jaunters go to at least the first location...
1138             request_jaunt(full_journey, TRUE);
1139             eventual_destination = (vector)llList2String(full_journey, llGetListLength(full_journey) - 1);
1140             llSetTimerEvent(POSITION_CHECKING_INTERVAL);
1141         }
1142     }
1143
1144     listen(integer channel, string name, key id, string message) {
1145         listen_to_voices(channel, name, id, message);
1146     }
1147
1148     timer() {
1149         if (jaunt_responses_awaited || child_needs_setup) {
1150             // we are not quite there yet.
1151             if (check_for_timeout()) state normal_runtime;  // oops.
1152             return;  // not time yet.
1153         }
1154         // we got to where we were going, maybe.
1155         // now unseat the avatar.  this leaves her at the destination.
1156         llUnSit(llAvatarOnSitTarget());
1157         state arrived_at_target;
1158     }
1159
1160     // process the response from the jaunting library.
1161     link_message(integer which, integer num, string msg, key id)
1162     { handle_link_message(which, num, msg, id); }
1163
1164     on_rez(integer parm) { state default; }  // start-up from scratch.
1165 }
1166
1167 // this state is activated when the first jaunt is complete.
1168 state arrived_at_target
1169 {
1170     state_entry() {
1171         if (DEBUGGING) log_it("=> arv_targ, pos=" + vector_chop(llGetPos()));
1172         // we are close enough; get back to work.
1173         jaunt_responses_awaited = 0;  // nothing pending right now.
1174         if ( ///(conveyance_mode != RECONNAISSANCE_TRIP) && 
1175         (conveyance_mode != AUTOREZ_JAUNTER) )
1176             llWhisper(0, "↣ " + llList2String(global_names, current_target_index));
1177
1178         // we've gotten where we were going.
1179         proclaim_arrival();
1180
1181         // reverse direction and head back without rider.
1182         eventual_destination = (vector)llList2String(full_journey, 0);
1183         request_jaunt(full_journey, FALSE);
1184         llSetTimerEvent(POSITION_CHECKING_INTERVAL);
1185         slackness_counter = 0;
1186     }
1187
1188     timer() {
1189         if (jaunt_responses_awaited) {
1190             // we are not quite there yet.
1191             if (check_for_timeout()) state normal_runtime;  // oops.
1192             return;  // not time yet.
1193         }
1194         if (!close_enough(eventual_destination))
1195             log_it("far away, path okay?");
1196         state normal_runtime;
1197     }
1198     
1199     // process the response from the jaunting library.
1200     link_message(integer which, integer num, string msg, key id)
1201     { handle_link_message(which, num, msg, id); }
1202
1203     on_rez(integer parm) { state default; }  // start-up from scratch.
1204 }
1205