|
Dameien Shippe
Registered User
Join date: 13 Sep 2008
Posts: 1
|
12-16-2008 20:54
Hey all, I'm new to scripting in SL and I am having an issue. I currently have a script that changes the texture of an object when a collision occurs. However due to lag the object can go grey for a bit before changing over to the new texture.
You might wonder what solution I am looking for...well the textures are identical, the only change between them is the color. I guess you could say the pattern of the texture is the same.
So what I want to do is on a collision with an Av, I want the texture to stay the same while the color of the object changes. I wrote a script that changes the color on collision but it isn't working. If i have the edit menu up, I see the color change in there but the object remains the same.
I might be explaining myself poorly, I can attempt to clarify if people have questions. Hopefully somebody has advice for me.
Thanks.
|
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
12-16-2008 22:28
Hard to say from here what the problem might be. Better post the script here.
|
|
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
|
12-17-2008 02:51
The gray you see is the place-holder while the texture being loaded into your client's memory. There's no way to preload a texture, unless you hide it first while it loads, then suddenly display it, and even then it's not guaranteed.
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
12-17-2008 05:56
One issue that's important to remember is that you can't actually change the colour of a texture... you can just sort of 'influence' it.
For example, if you have a white part of your texture, then you can make that like any colour at all... whether it's red or yellow or black. However, if you have a red texture, then you can't make that look green or blue, because you can't add primary colours which weren't there in the first place.
|
|
madddyyy Schnook
SLGuides Virtual Worlds
Join date: 2 Jan 2006
Posts: 207
|
12-18-2008 00:55
//-------------------------- // preloads textures on a box // just drop it in with the images and it will cycle every 10 seconds, or change the picture_pace variable to change the speed // updates on touch as well //--------------------------
// Change this next line to adjust the image rotation speed float picture_pace=10.0;
// Sendao Goodman, 2007
integer reload; list pictures; integer slideno;
loadPictures() { pictures=[]; integer i = llGetInventoryNumber(INVENTORY_TEXTURE); if( i > 0 ) { while( i > 0 ) { i--; pictures=(pictures=[])+pictures+[llGetInventoryName(INVENTORY_TEXTURE,i)]; } llOwnerSay((string)llGetListLength(pictures)+" pictures loaded"); pictures = llListSort( pictures, 1, TRUE ); // put them in order llSetTimerEvent(picture_pace); } else if( reload == 0 ) { llSetTimerEvent(0.0); } }
string getSlide(integer slide) { return llList2String( pictures, (slide+llGetListLength(pictures))%llGetListLength(pictures) ); }
default { on_rez(integer sp) { loadPictures(); slideno=0; reload=0; } state_entry() { loadPictures(); slideno=0; reload=0; llSetColor( <0,0,0>, 0 ); llSetColor( <0,0,0>, 1 ); llSetColor( <1,1,1>, 2 ); llSetColor( <0,0,0>, 3 ); llSetColor( <0,0,0>, 4 ); llSetColor( <0,0,0>, 5 ); } changed( integer ch ) { if( ch & CHANGED_INVENTORY ) { reload=1; llSetTimerEvent(2.0); } }
touch_start(integer nd) { if( llGetListLength(pictures) > 0 ) { integer i=6; while( i > 0 ) { i--; llSetTexture( getSlide(slideno+(i-2)), i); } slideno = (slideno+1)%llGetListLength(pictures); } }
timer() { if( reload == 1 ) { reload = 0; loadPictures(); return; } integer i=6; while( i > 0 ) { i--; llSetTexture( getSlide(slideno+(i-2)), i); } slideno = (slideno+1)%llGetListLength(pictures); } }
[code/]
dunno were i got this from so no shout outs to. but it preloads textures
edited to add the original scripters name
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
12-18-2008 08:14
That Preload Textures script is in the LSL wiki's library. If I understand the OP's question, though, he really doesn't need to cycle textures. All he needs to do is change the color of prim faces in his collision event. That's simply a matter of calling llSetPrimitiveParams, identifying the face, and specifying the new color. The reason he's having a lag problem is that he's changing the texture unnecessarily instead.
|