|
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
|
04-11-2007 09:05
Hi. I am using a script to hide and show an object. The problem is that the texture is not right when I show the object again. I know what the problem is in the script, but I don't know how to fix it. I thought that by using the "string llGetTexture(integer face);" command I might get the original texture and then be able to put it back. But I don't know what "integer face " means in the syntax or even what the command is really supposed to do. Anyway here is the script. The problem is the "key show=" value. I figure there are two ways to fix it. Either figure out the right key for my texture (which I don't know how to do) or somehow get the texture before hiding and restore it again. Any help would be appreciated. Oh and by the way, I'm kind of a dumb blonde so be gentle with me. Thanks - Dina ------------------------ //(c)Eggy Lippmann 2004 - Licensed to SL players under the GPL key hide="34fc26a7-6cb4-1300-a90f-d99214fd7801"; key show="63338ede-0037-c4fd-855b-015d77112fc8"; default { state_entry() { llListen(0,"","",""  ; } on_rez(integer param) { llResetScript(); } listen(integer c, string n, key k, string m) { if(m=="/show"  llSetTexture(show,ALL_SIDES); else if (m=="/hide"  llSetTexture(hide,ALL_SIDES); } } --------------
|
|
Vlad Bjornson
Virtual Gardener
Join date: 11 Nov 2005
Posts: 650
|
04-11-2007 09:26
You can get the UUID of your texture by finding it in your inventory, then right-clicking and choosing COPY UUID, then change the script to replace the show variable's value with your texture's UUID. You could also accomplish the same task without changing textures , by using the llSetAlpha command. http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetAlpha
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
04-11-2007 09:27
Yuck! There's quite a few things wrong with that script, but I will start with the most glaring. First, hide/show by changing the texture (by key of an uploaded asset, even!) is not the way to go about it. I am assuming the "hide" texture is probably a fully-transparent texture, and the "show" texture is something that Eggy had which was appropriate for one of his objects. Obviously, it was not appropriate for yours. The correct way to do it is to use an alpha change instead of a texture change, like so: integer giVisible = TRUE; integer giChannel = 2; float gfVisibleAlpha = 1.0; float gfHiddenAlpha = 0.0;
default { state_entry() { llSetAlpha(gfVisibleAlpha,ALL_SIDES); llListen(giChannel,"",llGetOwner(),""); } on_rez(integer piParameter) { llResetScript(); } listen(integer piChannel, string psName, key pkID, string psMessage) { psMessage = llToLower(psMessage); if (psMessage == "show") if (!giVisible) { llSetAlpha(gfVisibleAlpha,ALL_SIDES); giVisible = TRUE; } if (psMessage == "hide") if (giVisible) { llSetAlpha(gfHiddenAlpha,ALL_SIDES); giVisible = FALSE; } } }
The other glaring error is using a channel 0 listener. Well, it's not an error, per se, but it is a very bad practice. Always use a channel other than 0 unless you just can't do it any other way. The script above uses channel 2, which you would control it by typing "/2 show" and "/2 hide". Note that if your object is considered "visible" at any other alpha setting than 1.0, change the gfVisibleAlpha variable to that value. Same with the hidden alpha being anything other than 0.0. The script also does not change the alpha unless it is different than its current state, just for client efficiency's sake. 
|
|
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
|
04-11-2007 10:41
Hey wow and thanks. - Dina.
|