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
TExture Texture_Writer_Display_arbitrary_texture  

Texture_Writer_Display_arbitrary_texture

Each character uses one prim - in this incarnation.

This can be used to build a HUD (tiny prims) which can display messages or have a variable user interface. It can also be used to create large signs on which you can show messages.

There is a demonstration large sign in the Chessport sandbox. This one was created to display anything said on channel 0... this simple implementation doesn't feature a controller object for the display and so you need to shout, otherwise only prims near to you will react (try speaking normally to see what I mean).

There are two scripts involved. The first rezzes a set of tiles and the second is the script in the tile. The size of the final display depends on the size of the prims used for the tiles. The texture on the tiles must be set to
"bf84f91e-549f-e094-1693-278b6b521b12"

Category: TExture
By : Sparti Carroll
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Texture_Writer_Display_arbitrary_texture
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Texture_Writer_Display_arbitrary_te_1.lsl
Get file # 2. Texture_Writer_Display_arbitrary_te_2.lsl
1
2
3 //Rez Tiles Large (for linked sets - if that can be made to work)
4 // NB NegX is a temporary solution, it offsets tiles to negative X and uses different rotation (Zaxis 0) for writing along south edge of island
5 //21nov06 PG based on Rez Word Speakers
6 //Tells them which character position they are handling on rez
7 // should speak to children objects and tell them where to go etc. perhaps via bundled messages which they can split apart easily !={!} etc.
8 // option to vary size of wheels; select different fonts ? (drop in a new font texture not possible due child thing... hmmm)
9 // LOL - work of art. Make a wordprocessor, but a bit like moveable type, so if select different fonts etc then new wheels fly into place, can include images too... hmmm
10 // and spreadsheet ?
11 // make fruit machines !, or other gaming machines - have a small number of special prizes - vouchers for shops ? / start establishing chains of voucher accepting shops and
12 // have customer service level guarantees etc.
13
14 // Big cooperation game. 2 teams, randomly assigned
15 // Have to create a word, but at each location the player(s) only have control over 1 letter (each) - or perhaps as many as needed to make game work
16 // Or use coloured symbols/shapes instead of words... but still with a large texture map.
17 // Added listen and repeat to channel
18
19 // Fruit machine/ noughts and crosses machine
20
21 //Simple OpenSource Licence (I am trusting you to be nice)
22 //1. PLEASE SEND ME UPDATES TO THE CODE
23 //2. You can do what you want with this code and object including selling it in other objects and so on.
24 //You can sell it in closed source objects if you must, but please try to send any updates or
25 //improvements back to me for possible inclusion in the main trunk of development.
26 //3. You must always leave these instructions in any object created; notecard written; posting to
27 //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
28 //already requested!)
29 //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
30 //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
31 //Thank you for your co-operation
32 //sparti Carroll
33
34 integer iAbsoluteNumberOfObjects = 50;
35
36 key kOwner;
37 vector vMyPosition;
38 vector vRezOffset = <0,0,1>;
39
40 integer iFlagDebug = 0;
41
42 integer iFlagListenToOwnerOnly = 1;
43 integer iChannelListenToAvatars = 0;
44 integer iCommandChannel = 510; // normal speech in an area !!! DO NOT USE CHANNEL ZERO WITH OBJECTS IN DEBUG, OR IT GETS A BIT SILLY...!
45
46 DEBUG(list lBits) {
47 if(iFlagDebug) {
48 llSay(0, llList2CSV(lBits));
49 }
50 }
51
52 RezSingleObject(integer iObjectNumber) {
53 vector vRezPos = vMyPosition + vRezOffset;
54 DEBUG(["Try to rez at ",vRezPos," for object ",iObjectNumber]);
55 vector vRezRotEuler = <0,0,0> * DEG_TO_RAD;
56 rotation rRezRot = llEuler2Rot(vRezRotEuler);
57 // ZZZ note channel numbers are cannot be as large (/1000) compared to integer normally allowed. Also communication should be secured.
58 llRezObject("Texture Tile Hud Large",vRezPos,<0,0,0>,rRezRot,(iCommandChannel * 1000) + iObjectNumber +1); // +1 because start param of zero means rezzed as linked item not initial rez
59 }
60
61 RezObjects(integer iNumberOfObjects) {
62 integer i;
63 for (i = 0; i
64
65 Reset() {
66 kOwner = llGetOwner();
67 vMyPosition = llGetPos();
68 llListen(iChannelListenToAvatars,"","","");
69 }
70
71 default {
72 state_entry() {
73 DEBUG(["State entry"]);
74 Reset();
75 }
76
77 on_rez(integer start_param) {
78 Reset();
79 }
80
81 moving_end() {
82 Reset();
83 }
84
85 // ZZZ also listen to tile talkback channel
86 listen(integer iChannel,string sName,key kId,string sMessage) {
87 if(iChannel == iChannelListenToAvatars) {
88 if(iFlagListenToOwnerOnly == 0 || kId == kOwner) {
89 string sCommand = "SAY" + sMessage;
90 llShout(iCommandChannel,sCommand);
91 }
92 }
93 }
94
95 // XXX simple version rez when touched
96 touch_start(integer num_detected) {
97 key kAvatar = llDetectedKey(0);
98 if(kAvatar == kOwner) {
99 DEBUG(["Touched"]);
100 RezObjects(iAbsoluteNumberOfObjects);
101 }
102 }
103
104 }

Texture_Writer_Display_arbitrary_texture

Tile script

Category: TExture
By : Sparti Carroll
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 // Writer Tile Script
2 // NB NegX is a temporary solution, it offsets tiles to negative X and uses different rotation (Zaxis 0) for writing along south edge of island
3 // 16nov06 PG experiments with moving textures around in SL
4 // 21nov06 PG formerly Texture Wheel
5 // ZZZ use general block script, or derivative of it, so that instructions are spoken to block after rezzing, rather than all via start_param
6 // ZZZ use private high channel numbers for children - told via start_param
7 // make script which listens... when they are touched they increment their cell number
8 // they listen on private iMyChannel and pick out letter position to spin to from word said - for their cell number. Normally told cell number when rezzed by maker
9
10 //Simple OpenSource Licence (I am trusting you to be nice)
11 //1. PLEASE SEND ME UPDATES TO THE CODE
12 //2. You can do what you want with this code and object including selling it in other objects and so on.
13 //You can sell it in closed source objects if you must, but please try to send any updates or
14 //improvements back to me for possible inclusion in the main trunk of development.
15 //3. You must always leave these instructions in any object created; notecard written; posting to
16 //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
17 //already requested!)
18 //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
19 //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
20 //Thank you for your co-operation
21 //sparti Carroll
22
23
24 integer iMyChannel = -1; //I display things from messages spoken on this channel
25 integer iListen;
26 integer iMyCellNumber;
27 float fXStep;
28 float fYStep;
29 vector vRezPos; // Where I was rezzed
30 vector vBaseOffset = <0,0,1>; // all are shifted by this
31 vector vOffsetDelta;
32
33 integer iFlagDebug = 0; // really needs preprocessor
34
35 // characters in grid
36 string sGrid;
37
38 string sCurrentChar = "";
39
40 // HUD constants
41 integer HUDcenter2 = 31;
42 integer HUDtopright = 32;
43 integer HUDtop = 33;
44 integer HUDtopleft = 34;
45 integer HUDcenter = 35;
46 integer HUDbottomleft = 36;
47 integer HUDbottom = 37;
48 integer HUDbottomright = 38;
49
50 DEBUG(list lBits) {
51 if(iFlagDebug) {
52 llSay(0, llList2CSV(lBits));
53 }
54 }
55
56 set_hudpos(integer whereami) {
57 vector my_size = llGetScale();
58 vector v_atpos;
59 if(whereami == HUDbottomleft) v_atpos = <0,-my_size.y/2,0.06+my_size.z/2>;
60 else if(whereami == HUDtopleft) v_atpos = <0,-my_size.y/2,-0.06-my_size.z/2>;
61 else if(whereami == HUDbottom) v_atpos = <0,0,0.06 + my_size.z/2>;
62 else if(whereami == HUDbottomright) v_atpos = <0,0.5 + my_size.y,0.06 + my_size.z/2>;
63 else if(whereami == HUDtop) v_atpos = <0,0,-0.06-my_size.z/2>;
64 else if(whereami == HUDtopright) v_atpos = <0,0.5 + my_size.y,-0.06-my_size.z/2>;
65 else if(whereami == HUDcenter || whereami == HUDcenter2) v_atpos = <0,0,0>;
66 llSetPos(v_atpos);
67 }
68
69 DoAttach(key kAttachedTo) {
70 if(kAttachedTo != NULL_KEY) {
71 // something
72 if(iFlagDebug || iMyCellNumber == 0) {
73 // YYY move if cell 0 as only one need do it - might need cell 0 to be base of linked set...
74 // adjust position for HUD
75 integer whereami = llGetAttached();
76 if(whereami == 0) {
77 llOwnerSay("Please wear on the HUD");
78 } else {
79 set_hudpos(whereami);
80 }
81 }
82 }
83 }
84
85 Reset() {
86 fXStep = 16;
87 fYStep = 10;
88 if(iMyChannel != -1) {
89 AnnounceChannel();
90 }
91 sGrid = " !\"#$%&'()*+,-./0123456789:;<=>?";
92 sGrid += "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
93 sGrid += "'abcdefghijklmnopqrstuvwxyz{|}~";
94 // ZZZ bear in mind we could do entities/smilies even coloured ones!
95 // ZZZ could also include an escaping syntax so can refer to textures explicitly ??
97 vector vMyPrimSize = llList2Vector(lMyPrim,0);
98 DEBUG(["My Size is",vMyPrimSize]);
99 vOffsetDelta = <0,-vMyPrimSize.y,0>;
100 }
101
102 AnnounceChannel() {
103 DEBUG(["Channel",iMyChannel,", Cell Number",iMyCellNumber]);
104 }
105
106 SetPosition(vector targetpos) {
107 while(llVecDist(llGetPos(),targetpos) > 0.001) llSetPos(targetpos);
108 }
109
110 SetCorrectPosition() {
111 DEBUG(["Offset Delta is",vOffsetDelta]);
112 SetPosition(vRezPos + vBaseOffset + (iMyCellNumber * vOffsetDelta));
113 }
114
115 RotateToGridpos(integer iX,integer iY)
116 {
117 float fX = ((iX +- 0.5)/ fXStep);
118 float fY = ((iY - 0.5)/ fYStep);
119 DEBUG(["Cell ",iMyCellNumber,"moving to",fX,",",fY]);
121 }
122
123 RotateToGridposForChar(string sChar) {
124 // calculate position to use for display, for now we only do fairly standard characters
125 integer iX;
126 integer iY;
127 integer iPos = llSubStringIndex(sGrid,sChar);
128 if(iPos == -1) {
129 // unknown so rotate to blank
130 iX = -7;
131 iY =5;
132 } else {
133 integer iRow = iPos / 16;
134 integer iCol = iPos % 16;
135 iY = 5 - iRow;
136 iX = iCol - 7;
137 }
138 RotateToGridpos(iX,iY);
139 }
140
141 SetTextureCharacter(string sChar) {
142 if(iFlagDebug) {
143 DEBUG(["Cell ",iMyCellNumber,"setting char [",sChar,"]"]);
144 llSetText(sChar,<1,1,1>,1.0);
145 }
146 RotateToGridposForChar(sChar);
147 sCurrentChar = sChar;
148 }
149
150 Command_Say(string sMessage) {
151 if(iMyCellNumber > llStringLength(sMessage)) {
152 SetTextureCharacter(" ");
153 }
154 else {
155 string sOneChar = llGetSubString(sMessage,iMyCellNumber,iMyCellNumber);
156 SetTextureCharacter(sOneChar);
157 }
158 }
159
160 Command_Sax(string sMessage) {
161 // say command for one recipient
162 list lBits = llParseString2List(sMessage,[":"],[]);
163 integer iCellNumber = llList2Integer(lBits,0);
164 if(iCellNumber == iMyCellNumber) {
165 string sSetTo = llList2String(lBits,1);
166 // ZZZ could have extended character shift, or do that via different command, e.g. _Saw
167 SetTextureCharacter(sSetTo);
168 }
169 }
170
171 ProcessListen(string sMessage) {
172 DEBUG(["Message heard by ",iMyCellNumber," is [",sMessage,"]"]);
173 integer iMessageLength = llStringLength(sMessage);
174 if(iMessageLength >= 3) {
175 string sCommand = llGetSubString(sMessage,0,2);
176 string sParams = llGetSubString(sMessage,3,-1);
177 if(sCommand == "SAY") {
178 Command_Say(sParams);
179 } else if(sCommand == "SAX") {
180 Command_Sax(sParams);
181 }
182 }
183 }
184
185 default
186 {
188 {
189 DEBUG(["state_entry, channel=",iMyChannel]);
190 Reset();
191 DEBUG(["state_entry.after_Reset, channel=",iMyChannel]);
192 }
193
194 on_rez(integer start_param) {
195 DEBUG(["on_rez, channel=",iMyChannel]);
196 Reset();
197 if(start_param != 0) {
198 start_param -= 1;
199 iMyCellNumber = start_param % 1000; // 3 digits for cell number, so max limit 1000 cells in single rez - probably enough ?
200 iMyChannel = start_param / 1000; // channel number I will listen on
201 vRezPos = llGetPos();
202 SetCorrectPosition();
203 }
204 if(iMyChannel != -1) {
205 iListen = llListen(iMyChannel,"","","");
206 }
207 // ZZZ if cell 0 then link to others/request permission
208 DEBUG(["on_rez.after_Reset, channel=",iMyChannel]);
209 if(iMyCellNumber == 0) {
210 state master;
211 }
212 }
213
214 touch_start(integer total_number)
215 { // Send message back to control object: YYY would have to be llSay or llShout for non hud things
216 string sGoBack = "0"; // "1" will be 'go back area touched'
217 vector vTouchPos = llDetectedPos(0);
218 // ZZZ determine whether 'go back' clicked
219 string sNotify = (string)iMyCellNumber + ":" + sGoBack + ":" + sCurrentChar;
221 }
222
223 listen(integer iChannel, string sName, key kID, string sMessage) {
224 ProcessListen(sMessage);
225 }
226
227 attach(key kAttachedTo) {
228 DoAttach(kAttachedTo);
229 }
230 }
231
232 // Same but different for master object (0)
233 state master {
234 state_entry() {
235 DEBUG(["Muhahaha I am the master"]);
236 if(iMyChannel != -1) {
237 iListen = llListen(iMyChannel,"","","");
238 }
239 }
240
241 on_rez(integer start_param) {
242 // if rezzed and in master state we stay here (becoming master is irreversible and happens only once in objects lifetime
243 if(iMyChannel != -1) {
244 iListen = llListen(iMyChannel,"","","");
245 }
246 // ZZZ if cell 0 then link to others/request permission
247 DEBUG(["on_rez(MASTER).after_Reset, channel=",iMyChannel]);
248 }
249
250 touch_start(integer total_number)
251 { // Send message back to control object: YYY would have to be llSay or llShout for non hud things
252 string sGoBack = "0"; // "1" will be 'go back area touched'
253 vector vTouchPos = llDetectedPos(0);
254 // ZZZ determine whether 'go back' clicked
255 string sNotify = (string)iMyCellNumber + ":" + sGoBack + ":" + sCurrentChar;
256 DEBUG([iMyCellNumber," was touched"]);
258 }
259
260 link_message(integer iSender,integer iNum,string sMessage,key kId) {
261 // message received, something touched
262 llOwnerSay("Controller received [" + (string)iNum + "=" + sMessage + "]"); // ZZZ could actually rez a different object for the controller if we get short of single script space, or have extra script with link_message() only in controller
263 list lBits = llParseString2List(sMessage,[":"],[]);
264 integer iCellNumber = llList2Integer(lBits,0); // ok im not using it as integer here, but might later
265 integer iGoBack = llList2Integer(lBits,1);
266 string sNotifyChar = llList2String(lBits,2);
267 // YYY for testing: send back commands to swap with my char.
268 // Also note that these should be via message linked in first place (after hearing AV commands)
269 llSay(iMyChannel,"SAX:" + (string)iCellNumber + ":" + sCurrentChar);
270 SetTextureCharacter(sNotifyChar);
271 }
272
273 listen(integer iChannel, string sName, key kID, string sMessage) {
274 ProcessListen(sMessage);
275 }
276
277 attach(key kAttachedTo) {
278 DoAttach(kAttachedTo);
279 }
280 }

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