zzzz

Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Tour Guide waypoint_config  

waypoint_config

waypoint_config.lsl

Category: Tour Guide
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life + OpenSim

the Zip file

Download all files for waypoint_config
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. waypoint_config_1.lsl
1
2 list waypoints = [];
3 integer waypoint = 0;
4 integer chat_listener = 0;
5
6 string replaceString(string pattern, string replace, string source, integer count) {
7 while(count-- != 0) {
8 integer index = llSubStringIndex(source, pattern);
9 if(index < 0)
10 return source;
11 source = llInsertString(llDeleteSubString(source, index, (index + llStringLength(pattern) - 1)), index, replace);
12 }
13 return source;
14 }
16 if(c == TRUE)
17 return t;
18 else
19 return f;
20 }
21 show_dialog(key user) {
22 integer wpcount = llGetListLength(waypoints) >> 1;
23 llDialog(user,"We are at waypoint " + ((string)(waypoint+1)) + "/" + ((string)wpcount) + "\nPosition: " + (string)llList2Vector(waypoints,waypoint<<1) + "\nRotation: " + (string)llList2Rot(waypoints,(waypoint<<1)+1),[ce(waypoint > 0, "<", " "),"save",">","clear","load"],-19923);
24 }
25 save() {
26 if(waypoint >= llGetListLength(waypoints) >> 1)
27 waypoints = (waypoints=[]) + waypoints + [llGetPos(),llGetRot()];
28 else {
29 waypoints = llListReplaceList(waypoints, [llGetPos(), llGetRot()], waypoint << 1, (waypoint << 1) + 1);
30 }
31 }
32 unsave() {
33 if(waypoint >= llGetListLength(waypoints) >> 1)
34 save();
35 else {
36 llSetPos(llList2Vector(waypoints, waypoint << 1));
37 llSetRot(llList2Rot(waypoints, (waypoint << 1) + 1));
38 //llMoveToTarget(llList2Vector(waypoints, waypoint << 1),0.25);
39 //llRotLookAt(llList2Rot(waypoints, (waypoint << 1) + 1), 1, 0.25);
40 }
41 }
42 say() {
43 list tmp = [];
44 integer i = llGetListLength(waypoints);
45 vector sp = llList2Vector(waypoints, 0);
46 while(i>=2) {
47 tmp = (tmp=[]) + [llList2Vector(waypoints, i - 2) - sp, llList2Rot(waypoints, i - 1)] + tmp;
48 i-=2;
49 }
50 string str = "vector start = " + (string)sp + "; list waypoints = [" + llDumpList2String(tmp, ", ") + "];";
51 llSay(0, str);
52 }
53 default {
55 llListen(-19923,"","","");
56 save();
57 show_dialog(llDetectedKey(0));
58 }
59 listen(integer chan, string name, key user, string msg) {
60 if(chan == 0) {
61 if(llGetSubString(msg,0,4) != "load ")
62 return;
63 llListenRemove(chat_listener);
64 chat_listener = 0;
65
66 save();
67 say();
68
69 list tmp = llCSV2List(llGetSubString(msg,5,-1));
70 waypoints = [];
71 waypoint = 0;
72 while(waypoint<llGetListLength(tmp)) {
73 vector v = (vector)llList2String(tmp, waypoint++);
74 rotation r = (rotation)llList2String(tmp, waypoint++);
76 waypoints = (waypoints=[]) + waypoints + [v,r];
77 }
78
79 waypoint = 0;
80 unsave();
81 }
82 else if(msg == "<") {
83 save();
84 if(waypoint > 0)
85 waypoint--;
86 unsave();
87 }
88 else if(msg == ">") {
89 save();
90 waypoint++;
91 unsave();
92 }
93 else if(msg == "save") {
94 save();
95 say();
96 return;
97 }
98 else if(msg == "clear") {
99 save();
100 say();
101 waypoint = 0;
102 waypoints = [];
103 save();
104 }
105 else if(msg == "load") {
106 llSay(0,"Type \"load <x,y,z>,<x,y,z,s>,...\" in chat...");
107 chat_listener = llListen(0,"","","");
108 return;
109 }
110 else
111 llOwnerSay((string)name+"("+(string)chan+"): "+msg);
112 show_dialog(user);
113 }
114 }
115 // END //