Sending Texture Keys Between Unlinked Prims
|
|
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
|
05-20-2008 07:17
I found a script that takes the textures from the inventory of one prim, sends them to a LINKED prim and maps it on the prim. I need the same effect, but WITHOUT using linked prims (using llSay / llListen would be fine). Can someone help be get this to work? Thanks in advance: Original parent script using llMessageLinked (that I need to function with llSay)... <php> float time = 3.0; default { state_entry() { llSetText("",<1,1,1>,0); llSetTimerEvent(time); } timer() { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); integer choice = (integer)llFrand(number); string name = llGetInventoryName(INVENTORY_TEXTURE, choice); key textureid = llGetInventoryKey(name); if (name != ""  { llMessageLinked(LINK_SET,0,"",textureid); llSetTexture(name, ALL_SIDES); } } on_rez (integer start_param) { llResetScript(); } } </php> Original child script using link_message <php> default { link_message(integer sender_num, integer num, string str, key id) { llSetTexture(id, ALL_SIDES); } } </php>
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
05-20-2008 07:47
Simple exchange the llMessageLinked for an llSay, llWhisper or llShout to 'speak' the texure key on a channel that the other prim is listening on. The 'slave' script will now require a listen handler instead of a link_message handler but other wise the scripts remain nearly identical.
_____________________
I'm back......
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-20-2008 08:00
Right, But you have to cast the key to a string and back...
_____________________
From Studio Dora
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
05-20-2008 08:04
From: Dora Gustafson Right, But you have to cast the key to a string and back... lol yep but that is inherent in llSay as it only takes a string
_____________________
I'm back......
|
|
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
|
Texture not being properly mapped
05-20-2008 08:19
From: Newgate Ludd Simple exchange the llMessageLinked for an llSay, llWhisper or llShout to 'speak' the texure key on a channel that the other prim is listening on. The 'slave' script will now require a listen handler instead of a link_message handler but other wise the scripts remain nearly identical. Thanks for your reply. That's what I did. I also verified that the textureId is being sent and received (which it is), but the texture is not being mapped properly on the "slave" object. Instead, it just produces a gray texture. I checked the mapping parameters for the object, and I don't see where the problem is coming from. Any ideas?
|
|
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
|
llName2Key (not)
05-20-2008 08:41
From: Dora Gustafson Right, But you have to cast the key to a string and back... I used llKey2Name to cast a string, but I'm confused about how to get it back into a Key (as apparently there is no llName2Key function)??
|
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
05-20-2008 08:58
From: Kliger Dinkin I used llKey2Name to cast a string, but I'm confused about how to get it back into a Key (as apparently there is no llName2Key function)?? Oh, you don't want to use any of the functions, casting will work like: string texturetext = (string) texturekey;
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-20-2008 09:12
From: Kliger Dinkin ...the texture is not being mapped properly on the "slave" object. Instead, it just produces a gray texture. Are you sure the texture had time to load on your client? That sounds like what an unrezzed texture looks like. Also, are you sure you aren't zoomed in on some gray featureless portion of the texture? Try setting the texture scale and offset to their default values.
|
|
Kliger Dinkin
Registered User
Join date: 22 Apr 2006
Posts: 46
|
05-20-2008 12:20
From: Viktoria Dovgal Oh, you don't want to use any of the functions, casting will work like:
string texturetext = (string) texturekey; Thnx all. I figured it out and learned all about typecasting in the process.
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-20-2008 15:44
all depends on what exally you do but, ta that is the most efficent way if they within range, if you cose to have the prims change texture from farther away i would use llEmail to email the prim if farther than 1 sim away EDIT: i was in a scripting mood this is basicly all you had to change take out the llLinkedMeassages and replace them with a shout and a listen, the main prim checks every 3 seconds and if the texture changes or however this is set up it wil shout the new texture key to the child prim that listens, (-) channels are the best for object related since avatars themaself cant use (-) channels /// Main Prim \\\ float time = 3.0; integer channel = 20; // channel to shout it on default { state_entry() { llSetText("",<1,1,1>,0); llSetTimerEvent(time); } timer() { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); integer choice = (integer)llFrand(number); string name = llGetInventoryName(INVENTORY_TEXTURE, choice); key textureid = llGetInventoryKey(name); if (name != "") { llShout(-channel,(string)textureid); llSetTexture(name, ALL_SIDES); } } on_rez (integer start_param) { llResetScript(); } }
/// "Child" Prim \\\
integer channel = 20; // channel to listen on default { state_entry() { llListen(-channel,"","",""); } listen( integer channel, string name, key id, string message ) { llSetTexture((string)message, ALL_SIDES); } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-20-2008 16:12
If using plain chat you might consider also obfuscating the texture keys if you aren't comfortable with an obscure channel offering all your security. Once someone has your texture's key, that's almost as good has having the (full permission) texture itself; the only difference I'm aware of being that they can't download it (using standard client features) to their computer to create untraceable copies and derivative works. A simple way to do this is using logic like: string SECRET_KEY = "some secret phrase here";
string encrypt(string plaintext) { return llXorBase64StringsCorrect(llStringToBase64(plaintext), SECRET_KEY); }
string decrypt(string cyphertext) { return llBase64ToString(llXorBase64StringsCorrect(cyphertext, SECRET_KEY)); }
(With a fixed, short secret key like this it isn't anything approaching secure encryption, but it's probably good enough to obfuscate texture keys across chat.)
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
05-20-2008 16:54
got to love encrypations
|