Cris Poliak
Registered User
Join date: 14 Apr 2008
Posts: 27
|
01-29-2010 20:27
Well.. As you can see it's a simple script that shows some textures stored inside one prim and then it works like a photo album (Although I don't want to make it to work for that purpose) The right prim(2nd one) will store the textures inside it and the main script.. and another script that will catch the messages if I want to change to the next texture.. The script works fine... but it turns slowly if I want to change to the next/previous texture. Can anybody help me with these? The texture ID shown in here is a blank texture... Main script: link_message(integer sender_num, integer num, string msg, key id) { if ( msg == "NEXT" ) { currentTexture++; }//if if ( msg == "PREV" ) { currentTexture--; }//if llSetTexture( llGetInventoryName( INVENTORY_TEXTURE, currentTexture ), 0); }//link_message
The prev script is on the other prim linked to the 2nd prim(The one that contains the main script) Why is it so laggy? What can I do instead of it? Thanks in advance. Regards. Cris.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-29-2010 21:21
well for starters you're calculating and passing around a lot of information that isn't being used anywhere we can see.... for instance, you send out not only the key of the current texture, but also null key, to every script including the main, which then has to reprocess that (causing the texture to be applied in an endless loop of link messages, since you don't check the message before applying the texture) in your button script your passing the touchers key to the main script (and every other script), but never using it. on top of that all, inventory functions can run slow. try this instead. link_message(integer sender_num, integer num, string msg, key id){ if (numberTextures){ //don't bother if we don't have any to change if (("NEXT" == msg) || ("PREV" == msg)){ //don't bother if it's not our command if ("NEXT" == msg){ //-- add one ++currentTexture; }else{ //subtract one --currentTexture; } currentTexture = (currentTexture + numberTextures) % numberTextures; //-- wrap index safely llSetTexture( llGetInventoryName( INVENTORY_TEXTURE, currentTexture ), 0); } } }
also use "" instead of NULL_KEY or llDetectedKey( 0 ) if you aren't actually using those on the receiving end. (and if you DO need to send out the current textures key, it's better to use the key field so you don't have to convert) PS don't you quote tags for scripts, as they don't show up at all in the reply window, and the formatting is lost. use php tags, if you can't see those properly, follow the link in my signature below for a fix. PPS there's no point in having a touch handler in the main script unless you are using it
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Cris Poliak
Registered User
Join date: 14 Apr 2008
Posts: 27
|
01-29-2010 22:59
Thank you, It works fine now, but only for the second prim. I'll make the proper adaptations for it =)
|
Cris Poliak
Registered User
Join date: 14 Apr 2008
Posts: 27
|
02-08-2010 05:24
Hello again. Since I solved the part that sends the data to the other prim linked to the root one, now it shows both textures (prev and last) to the proper faces of each prim. But I found another error that makes the script to work in a different way that the idea I've got in mind. Once it reaches the last texture or the first one, it throws an error. I know that it is because the index. If I'm on the first one and I try to click on "prev" it tries to show a wrong texture, same applies for the last one. I currently changed the number of textures to skip so it can also work as a book. Any ideas? Here's the code snipped: link_message(integer sender_num, integer num, string msg, key id) { if (numberTextures) { //don't bother if we haven't got anything to change if (("NEXT" == msg) || ("PREV" == msg)) { //Don't bother if it's not our command if ("NEXT" == msg ) { //-- add one if ( currentTexture < numberTextures-1 ) { currentTexture+=2; } } else { //substract one if ( currentTexture < numberTextures-1 && currentTexture!=0 ) { currentTexture-=2; } else { currentTexture=0; } } currentTexture = (currentTexture + numberTextures) % numberTextures; //-- wrap index safely llSetTexture( llGetInventoryName( INVENTORY_TEXTURE, currentTexture ), 0); llMessageLinked(LINK_SET,1,(string)llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE, currentTexture-3)),NULL_KEY); } } }//link_message
Thank you =)
|