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
NPC OpenSim Mirror  

OpenSim Mirror

NPC Mirror Make a NPC appear that looks just like thee

Category: NPC
By : Ferd Frederix
Created: 2013-09-08 Edited: 2014-02-14
Worlds: OpenSim

the Zip file

Download all files for OpenSim Mirror
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Animation2.bvh
Get file # 2. Animation3.bvh
Get file # 3. Animation4.bvh
Get file # 4. OpenSim Mirror.lsl
Get file # 5. sit Pose.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 // Requirements:
2 // A pose ball or a chair prim with this script, and a second prim named "npcChair" with the other script
3 // Needs at least one, and no more than 12 sit animations.
4 // NPC's have to be enabled.
5
6 // Tunable stuff, like positions of prims, name of chair, and camera controls.
7 string stand = "avatar_jumpforjoy"; // the name of a animation of you standing there. plays when you stand up.
8
9 string chairName = "npcChair"; // the name of the prim the npc will sit on
10 vector myPos = <0.0, 0.0, 0.1>; // my pos relative to the pose ball
11 vector npcPos = <-3.0, 0, 0>; // npc rez pos relative to the pose ball
12 vector myEye = <-1, 0, 0>; // my eyeball
13 vector myFocus = <-5, 0, -100>; // is looking at this spot
14
15
16 // stuff best left alone
17 integer chat = -483498; // chqnnel to command the NPC pose ball to appear
18 key aviKey ; // who is sitting
19 key npc; // save the npc key
20 vector npcPOS; // calculate the position of the npc;
21 integer listener; // a place to hold a listen id that we can remove
22 list poses; // a list of poses
23 string last_anim; // the last animation we ever played
24
25
26 // Display a dialog box with up to 12 animations
27 dialog()
28 {
29 llListenRemove(listener);
30 integer channel = llCeil(llFrand(10000)+20000);
31 listener = llListen(channel,"","","");
32
34 integer index;
35 poses = [];
36 for ( ; index < poseCount; index++) {
38 if(llGetSubString(name,0,2) == "sit")
39 poses += name;
40 }
41 poses = llDeleteSubList(poses,12,99); // no more than 12, please
42
43 llDialog(aviKey,"Pick a pose",poses,channel);
44
45 }
46
47
48 default {
49
50 // reset when rezzed so any mirror gets fixed
51 on_rez(integer param)
52 {
54 }
55
56 // on reset event is next
57 state_entry() {
58 llSetText("Mirror",<1,1,1>,1.0);
59 llSay(chat,"Mirror");
61 osNpcRemove(llGetObjectDesc()); // kill any old miror off
62
63 // set sit target, otherwise this will not work
64 llSitTarget(myPos, ZERO_ROTATION); // one forware, not to the size, 1 up.
65
66 llSetCameraEyeOffset(myEye); // and set the camera up
67 llSetCameraAtOffset(myFocus);
68 }
69
70 changed(integer what) {
71
72 // someone sat
73 if(what & CHANGED_LINK) {
74
75 aviKey = llAvatarOnSitTarget(); // save for whom the mirror tolls
76 if(aviKey != NULL_KEY) {
77 llRequestPermissions(aviKey,PERMISSION_TRIGGER_ANIMATION); // we need permission to control animations, so ask for it
78
79 } else { // OMG, they unsat. Must not like their own face.
80 llSetText("Mirror",<1,1,1>,1.0);
81 llSay(chat,"Mirror");
82
84 osNpcStopAnimation(npc,last_anim); // stop whatever animation was playing
85 osNpcStand(npc); // stand up
86 osNpcPlayAnimation(npc,stand);
87 llStopAnimation(last_anim);
88 llStartAnimation(stand);
89 llSleep(5);
90 osNpcSay(npc, 0, "Goodbye"); // lets not be snarky. Just say goodbye
91 osNpcRemove(npc); // and die a horrible death while they watch
92 llStopAnimation(stand);
93 }
94 }
95 }
96
97
98 run_time_permissions(integer permissions)
99 {
100 // Now we have permission to kill the men, burn the village and rape the women. And let's get it right this time!
101 if(permissions & PERMISSION_TRIGGER_ANIMATION)
102 {
103 llSetText("",<1,1,1>,1.0);
104 llSay(chat,"");
106
107 llStopAnimation("sit"); // end the default "sit"
108 last_anim = llGetInventoryName(INVENTORY_ANIMATION,0); // find the first animation in inventory
109 llStartAnimation(last_anim); // We could paint it black, or start it up.
110
111 string fullName = llKey2Name(aviKey); // get the name of the avatar.
112 list fl = llParseString2List(fullName,[" "],[]); // make a list of avatars name, split apart at the space
113 string fname = llList2String(fl,0); // get first name from 0th element of the list
114 string lname = llList2String(fl,1); // 1th element is the last name
115
116 npcPOS = llGetPos() + npcPos; // npc will REZ here
117
118 npc = osNpcCreate(fname, lname, npcPOS, llAvatarOnSitTarget());
119 llSetObjectDesc(npc); // save it in case we get reset
120 llSetTimerEvent(5); // give it time to rez
121 }
122 }
123
124
125 timer()
126 {
128
129 llSensor(chairName,"",PASSIVE|SCRIPTED,10.0,TWO_PI); // look around 10 meters for something to sit on
130 }
131
132 sensor (integer n)
133 {
134 osNpcSit(npc, llDetectedKey(0), OS_NPC_SIT_NOW); // sit on the detected seat
135 osNpcStopAnimation(npc,"sit");
136 osNpcPlayAnimation(npc,last_anim);
137 dialog();
138 }
139
140 no_sensor()
141 {
142 llOwnerSay("Mirror cannot find the a chair named " + chairName);
144 }
145
146 listen(integer channel, string name, key id, string message)
147 {
148 llStopAnimation(last_anim);
149 llStartAnimation(message);
150 osNpcStopAnimation(npc,last_anim);
151 osNpcPlayAnimation(npc,message);
152
153 last_anim = message;
154 dialog();
155 }
156
157 }

OpenSim Mirror

A chair for the NPC to sit in

Category: NPC
By : Ferd Frederix
Created: 2013-09-08 Edited: 2014-02-14
Worlds: OpenSim


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 // put this in a prim for the NPC to sit on
3
4 vector myPos = <0.0, 0.0, 0.1>; // sit pose relative to the pose ball, must NOT be all zeros!
5 integer chat = -483498;
6
7 default
8 {
10 {
12 llListen(chat,"","","");
13
14 llSitTarget(myPos, ZERO_ROTATION); // one forware, not to the size, 1 up.
15 }
16
18 {
20 }
21 listen(integer channel, string name, key id, string str)
22 {
23 if(str == "Mirror")
24 {
25 llSetText(str,<1,1,1>,1.0);
27 }
28 else
29 {
30 llSetText(str,<1,1,1>,1.0);
32 }
33 }
34 }

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