Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Sphere World Sphere_World__Walk_and_live_on_a_sphere  

Sphere_World__Walk_and_live_on_a_sphere

Put this in a large sphere.
It sends the sphere's size and position to the pose balls
You can then make the sphere any size, click the sphere, and pose balls will move to the correct radius
Thanks to Shameena Short for reporting bugs!

Category: Sphere World
By : Ferd Frederix
Created: 2013-12-13 Edited: 2013-12-13
Worlds: Second Life

the Zip file

Download all files for Sphere_World__Walk_and_live_on_a_sphere
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Moon.lsl
Get file # 2. Random Walk on the Moon.lsl
Get file # 3. README.txt
Get file # 4. Walk Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Sphere script for walking on a planet or moon
3 // global listeners
4
5 integer To_Pose_CHANNEL = 98798771;
6 integer To_Planet_CHANNEL = 65835861;
7
8
9
10 Say()
11 {
12 vector size = llGetScale();
13
14 vector pos = llGetPos();
15 string place = "SPHERE^" + (string)pos + "^" + (string)size.x ;
16 llShout(To_Pose_CHANNEL, place);
17 llOwnerSay("Sending " + place);
18
19
20 }
21 default
22 {
24 {
25 llTargetOmega(<.5,0.0,0.0>*llGetRot(),0.1,0.01);
26
27 llListen(To_Planet_CHANNEL, "", "", ""); // listen for a pet to say XSPET_PING_HOME - Mod by Ferd to listen to HOME_CHANNEL, not -237918
28 Say();
29 }
30
31 touch_start(integer total_number)
32 {
33 if(llDetectedKey(0) == llGetOwner()) {
34
35 Say();
36 }
37
38 }
39
40 listen(integer channel, string name, key id, string msg)
41 {
42 llOwnerSay("Sphere Heard :" + msg);
43 vector size = llGetScale();
44 vector pos = llGetPos();
45
46 //pos.z = pos.z - size.z / 2;
47
48 Say();
49 }
50 }
51

Sphere_World__Walk_and_live_on_a_sphere

Pose ball - put this in a small sphere and set it at ground level.
When you click it, it will let you walk on your sphere world
Also Add a walk animation named "walk" to the prim, too
Thanks to Shameena Short for reporting bugs!

Category: Sphere World
By : Ferd Frederix
Created: 2013-12-13 Edited: 2013-12-13
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // walk on a moon pose ball
3 // Put this script into a pose ball and set it near your Sphere world.
4 // This allows the person to actually welk on your world using the arrow ketys
5
6 // Requires there to be one Walk animation in the inventory of the pose ball.
7
8
9 integer debug = FALSE;
10 DEBUG(string msg)
11 {
12 if(debug)
13 llOwnerSay(llGetScriptName() + ":" + msg);
14
15 }
16
17 integer To_Pose_CHANNEL = 98798771;
18 integer To_Planet_CHANNEL = 65835861;
19
20 string Copyright = " (c) 2012 by Ferd Frederix"; // You cannot change this line. See License agreements above. Attribution is required, and these files are copyrighted.
21
22 vector home_location;
23 vector destination;
24 integer rest;
25
26
27 // walk on a sphere
28
29 rotation gOrient;
30
31 integer gCounter;
32
33 string ANIMATION;
34
35 key avatarKey;
36 float x ;
37 float y ;
38 float z ;
39 float gRADIUS;
40 float aRADIUS;
41
42
43 face_target(vector lookat) {
44 rotation rot = llGetRot() * llRotBetween(<1.0 ,0.0 ,0.0 > * llGetRot(), lookat - llGetPos());
45
46 llSetRot(rot);
47
48 rot = llGetRot() * llRotBetween(<0.0 ,0.0 ,1.0 > * llGetRot(), home_location - llGetPos());
49 llSetRot(rot);
50 }
51
52 key avatar;
53
54
55 vector Home;
56
57 default
58 {
59
61 {
63 }
64
66 {
67
68 Home = llGetPos();
69
71 llSetText("Walk on the moon",<1,1,1>,1);
72 vector rot = <0,180,180>;
73 rotation sitrot = llEuler2Rot(rot * DEG_TO_RAD);
74 llSitTarget(<0,0,0.01>,sitrot);
75
76 llListen(To_Pose_CHANNEL, "", "", "");
77 llShout(To_Planet_CHANNEL, "PING_WORLD");
78 }
79
80
81 listen(integer channel, string name, key id, string message)
82 {
83 list data = llParseString2List(message, ["^"], []);
84
85 DEBUG(llDumpList2String(data,","));
86
87 if(llList2String(data, 0) == "SPHERE")
88 {
89 DEBUG("SPHERE");
90
91 vector n_home_loc = (vector) llList2String(data, 1);
92 vector my_loc = llGetPos();
93
94 DEBUG("dist:" + (string)llVecDist(n_home_loc, my_loc) + " Home:" + (string)n_home_loc + " Name:" + llList2String(data, 4));
95
96 if(llGetOwnerKey(id) == llGetOwner())
97 {
98 home_location = n_home_loc;
99 DEBUG("Home loc:" + (string) home_location);
100
101 float dia = llList2Float(data, 2);
102
104 {
105 gRADIUS = dia/2;
106
107 //home_location.y -= dia/2;
108
109 DEBUG("Home Radius:" + (string) gRADIUS);
110
111 DEBUG("Orbit Set");
112
113 state running;
114 }
115 }
116 }
117 }
118 }
119
120
121 state running
122 {
124 {
125 llOwnerSay("running");
126 gOrient = ZERO_ROTATION;
127 destination = <0,0,0>;
128 vector current_loc = llGetPos();
129
130 llListen(To_Planet_CHANNEL, "", "", "");
131 }
132
134 {
136 {
137 vector height = llGetAgentSize(avatarKey);
138
139 aRADIUS = gRADIUS + height.z * .85 ; // adjust for the agent size
140
141 llStopAnimation("sit");
142 llStartAnimation("walk");
143 ANIMATION = "walk";
145 llSetText("",<1,0,0>,1);
147 }
148 }
149
150
151
152
153 changed(integer change)
154 {
155 if(change & CHANGED_LINK)
156 {
157 avatar = llAvatarOnSitTarget();
158 if(avatar != NULL_KEY){
159 //SOMEONE SAT DOWN
160 avatarKey = avatar;
162
163 }else{
164 //SOMEONE STOOD UP
166 {
168 llStopAnimation(ANIMATION);
169 llSetText("Walk on the Moon",<1,1,1>,1);
171 llSetRegionPos(Home);
172 }
173 }
174 }
175 }
176
177
178
179 timer()
180 {
181 if(rest)
182 {
183 //llSetText((string) rest,<1,0,0>,1);
184 rest--;
185
186 rotation delta = llEuler2Rot(<x,y,z> * DEG_TO_RAD);
187
188 vector unitpos = llRot2Fwd( gOrient );
189 vector pos = home_location + unitpos * aRADIUS;
190
191 DEBUG((string) llVecDist(home_location,llGetPos()));
192
193 gCounter++;
194 face_target(pos);
195 llSetRegionPos(pos);
196
197 gOrient = gOrient * delta;
198
199 }
200 else
201 {
202 x = llFrand(5) + 5;
203 y = llFrand(5) + 5;
204 z = llFrand(5) + 5;
205
206 if(llFrand(2) > 1)
207 x = 1-x;
208 if(llFrand(2) > 1)
209 y = 1-z;
210 if(llFrand(2) > 1)
211 z = 1-z;
212
213 rest = (integer)llFrand(12.0) + 1;
214
215 }
216
217 }
218
219
220
221 }

Sphere_World__Walk_and_live_on_a_sphere

Notes on how to make things walk on a sphere

Category: Sphere World
By : Ferd Frederix
Created: 2013-12-13 Edited: 2013-12-13
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 Make a large sphere. Add the moon script. Put it somewhere within 100 meters of the ground.
3
4 Put the pose ball script in a small sphere at ground level, along with one walk animation named 'walk'.
5 Click the pose ball to auto-walk around on your moon.
6
7 A second pose ball script requires a '"Walk: Power Slow' and a 'avatar_stand_1",
8 or you can edit that script and change to any suitable alk and stand animation from your inventory.
9
10 string WALK = "Walk: Power Slow";
11 string STAND = "avatar_stand_1";
12
13 You can put out have as many pose balls as you want.

Sphere_World__Walk_and_live_on_a_sphere

Controlled Walk Pose ball - put this in a small sphere and set it at ground level.
Add a walk animation named "Walk: Power Slow" to the prim, and an animation named "avatar_stand_1".
You can rename these to match or rename them in the sceript.
When you click it, it will let you walk on your sphere world

Category: Sphere World
By : Ferd Frederix
Created: 2013-12-13 Edited: 2013-12-13
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 string Text = "Live on the Moon"; // the hovertext when no one is stting
3 string WALK = "Walk: Power Slow";
4 string STAND = "avatar_stand_1";
5
6 // Requires there to be one walk animation in the inventory of the pose ball.
7
8
9 integer debug = FALSE;
10 DEBUG(string msg)
11 {
12 if(debug)
13 llOwnerSay(llGetScriptName() + ":" + msg);
14
15 }
16
17 // global listeners
18
19 integer To_Pose_CHANNEL = 98798771;
20 integer To_Planet_CHANNEL = 65835861;
21
22 // walk on a sphere
23
24
25 string ANIMATION ; // change to a walk animation
26
27
28 vector gSphereLocation; // location of the walkable sphere
29 vector Home; // pose ball home
30 rotation gOrient;
31 list gSilly_walks;
32
33 rotation sphereRot;
34
35
36 vector priorpos;
37 key avatarKey;
38 float x ;
39 float y ;
40 float z ;
41 float gRADIUS = 0.0;
42 float aRADIUS;
43 string controls ;
44
45
46 spin()
47 {
48 llTargetOmega(<0.5,0.0,0.0>*llGetRot(),0.1,0.01); // start spin
49 }
50
51 stopSpin()
52 {
53 llTargetOmega(<0.0,0.0,0.0>*llGetRot(),0.1,0.01); // start spin
54 }
55
56 uSteppedLookAt( vector vPosTarget, float vFltRate ){
57 rotation vRotTarget = llRotBetween( <1.0, 0.0, 0.0>, vPosTarget );
58 if((integer)(vFltRate = llAcos( (vPosTarget = llVecNorm( vPosTarget )) *
59 (<1.0, 0.0, 0.0> * llGetLocalRot()) ) / (vFltRate / 5.0))){
60 rotation vRotStep = llAxisAngle2Rot( llRot2Axis( vRotTarget / llGetLocalRot() ),
61 (1.0 / vFltRate) * llRot2Angle( vRotTarget / llGetLocalRot() ) );
62 vFltRate = (integer)vFltRate;
63 do{
64 llSetLocalRot( vRotStep * llGetLocalRot() );
65 }while( --vFltRate );
66 }
67 llSetLocalRot( vRotTarget );
68 } //-- for fixed time on any rotation try llKeyframeMotion
69
70
71 face_target(vector lookat) {
72
73 rotation rot = llGetRot() * llRotBetween(<0.0 ,0.0 ,1.0 > * llGetRot(), gSphereLocation - llGetPos());
74 llSetRot(rot);
75 }
76
77 key avatar;
78
79
80 warpPos( vector destpos )
81 {
82 llOwnerSay("tp to: " + (string) destpos);
83
84 llSetRegionPos(destpos);
85
86 }
87
88 Fetch(key id, string message)
89 {
90 if(llGetOwnerKey(id) == llGetOwner())
91 {
92 DEBUG("walk script Heard " + message);
93
94 list data = llParseString2List(message, ["^"], []);
95
96 if(llList2String(data, 0) == "SPHERE")
97 {
98 gSphereLocation = (vector) llList2String(data, 1);
99 float dia = llList2Float(data, 2);
100 gRADIUS = dia/2;
101 llOwnerSay("Sphere located at " + (string) gSphereLocation);
102 Home = llGetPos();
103 state running;
104 }
105 }
106 }
107
108 default
109 {
110
112 {
114 }
115
117 {
118
119
120 ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0); // get the first animation we can find
121
122 llSetAlpha(1,ALL_SIDES); // visible
123 llSetText(Text,<1,1,1>,1); // set hover text
124
125 // sitting
126 vector rot = <0,90,180>; // 0, 90, 180 for avatar position
127 rotation sitrot = llEuler2Rot(rot * DEG_TO_RAD);
128 llSitTarget(<0,0,0.01>,sitrot);
129
130 // position
131 vector arot = <270,0,270>; // 0, 90, 180 for avatar position
132 sphereRot = llEuler2Rot(arot * DEG_TO_RAD);
133 llSetRot(sphereRot);
134
135 spin();
136
137 // listen for world position and size
138 llListen(To_Pose_CHANNEL, "", "", "");
139 llRegionSay(To_Planet_CHANNEL, "PING");
140
141 // camera
142 llSetCameraEyeOffset(<-4, 0, 3> * sitrot);
143 llSetCameraAtOffset(<2, 0, 1> * sitrot);
144 }
145
146
147 listen(integer channel, string name, key id, string message)
148 {
149 Fetch(id,message);
150 }
151
152
153 }
154
155 state running
156 {
158 {
159 gOrient = ZERO_ROTATION;
160 Home = llGetPos();
161 llListen(To_Pose_CHANNEL, "", "", "");
162 }
163
164 listen(integer channel, string name, key id, string message)
165 {
166 Fetch(id,message);
167 }
168
169 changed(integer change)
170 {
171 if(change & CHANGED_LINK)
172 {
173 avatar = llAvatarOnSitTarget();
174 if(avatar != NULL_KEY){
175
176 if(gSphereLocation == <0,0,0>) {
177 llOwnerSay("World not located yet, please click the sphere world and make sure it is within 100 meters");
178 return;
179 }
180
181 //SOMEONE SAT DOWN
182 avatarKey = avatar;
184
185 }else{
186 //SOMEONE STOOD UP
188 {
189 llStopAnimation(ANIMATION);
190 }
191
193 llSetText(Text,<1,1,1>,1);
195 warpPos(Home);
196 llSetRot(sphereRot);
197 spin();
198 }
199 }
200 }
201
203 {
205 {
206
207 vector height = llGetAgentSize(avatarKey);
208 aRADIUS = gRADIUS + height.z * 0.50 ; // adjust for the agent size
209
210 vector unitpos = llRot2Fwd( gOrient );
211 vector pos = gSphereLocation + unitpos * aRADIUS;
212
213 warpPos(pos);
214
215 llStartAnimation(STAND);
216 llStopAnimation("sit");
217
218 llSetTimerEvent(.5); // look for walking
219 llSetText("",<1,0,0>,1); // no text
220 llSetAlpha(0,ALL_SIDES); // invisible
221 stopSpin();
222 }
224 {
225 //llOwnerSay("Controls Ready");
230 controls = "U";
231 }
232 }
233
234 timer()
235 {
236
237 if(llStringLength(controls) == 0)
238 {
239 llStartAnimation(STAND);
240 llStopAnimation(WALK);
241 return;
242 }
243
244 //llOwnerSay(controls);
245 controls = "";
246 llStartAnimation(WALK);
247 llStopAnimation(STAND);
248
249 rotation delta = llEuler2Rot(<x,y,z> * DEG_TO_RAD);
250
251 vector unitpos = llRot2Fwd( gOrient );
252 vector pos = gSphereLocation + unitpos * aRADIUS;
253
254 //llOwnerSay((string) llVecDist(gSphereLocation,llGetPos()));
255
256 // face_target(pos);
257
258 //llLookAt( pos, 1.0, 0.1);
259
260 // if(pos != priorpos)
261 // {
262 // llOwnerSay("rotating");
263 // uSteppedLookAt(pos,2.0);
264 // priorpos = pos;
265 // }
266 llSetRot(gOrient);
267
268 //llRezObject("Pointer",pos,<0,0,0>,gOrient,1);
269 //llOwnerSay("Pos:" + ( string) pos);
270
271 llSetPos(pos);
272
273 gOrient = gOrient * delta;
274 }
275
276
277 control(key driver, integer levels, integer edge)
278 {
279
280 // integer start = levels & edge;
281 // integer end = ~levels & edge;
282 // integer held = levels & ~edge;
283 //integer untouched = ~(levels | edge);
284 //llOwnerSay(llList2CSV([levels, edge, start, end, held, untouched]));
285
286 //z = L/R
287 //y = U/d
288 x = 0;
289 y = 0;
290 z = 0;
291
292 float bump = 10;
293
294 if(levels & CONTROL_FWD)
295 {
296 y = -bump;
297 controls = "U";
298 }
299 if(levels & CONTROL_BACK)
300 {
301 y = bump;
302 controls = "D";
303 }
304 if(levels & CONTROL_ROT_LEFT)
305 {
306 z = bump ;
307 controls = "L";
308 }
309 if(levels & CONTROL_ROT_RIGHT)
310 {
311 z = -bump;
312 controls = "R";
313 }
314
315
316
317
318 }
319
321 {
323 }
324
325
326 }

Back to the Best Free Tools in Second Life and OpenSim.