Need help with a texture animation script
|
Wynx Whiplash
Registered User
Join date: 25 Sep 2004
Posts: 339
|
12-06-2004 10:34
I have a simple "texture switcher" script. It works great, but I want to have 2 prims with the same picture switching at the same time. How can I get them to synchronize? Can I just add a bit to the script I currently have? Or is the trick in how it's built? Here's the script I have... I bought it for a dollar a while back. Hope I'm posting the script correctly. default { state_entry() { llSetText("",<1,1,1>,0); llSetTimerEvent(0.5); } timer() { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  llSetTexture(name, ALL_SIDES); } on_rez (integer start_param) { llResetScript(); } }
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
12-06-2004 12:41
Wynx, If your two prims are linked, in your code you should set up a llMessageLinked() command to tell the other prim what to display. They should sync up nicely that way. So right after your line that does the display: llSetTexture(name, ALL_SIDES); send a linked message to the other prim. Set up a "link listener" in the other prim and you should be good to go. Look at Linked messages in the Wiki. (yeah the wiki is back)
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Wynx Whiplash
Registered User
Join date: 25 Sep 2004
Posts: 339
|
12-06-2004 14:13
|
Wynx Whiplash
Registered User
Join date: 25 Sep 2004
Posts: 339
|
12-06-2004 14:43
On closer inspection, I have decided that I am a fair artist and a completely hopeless scripter. My head is spinning. Would someone be so kind as to show me exactly what the llMessageLinked() should look like on the parent and the linked message for the child prim? I only need 2 prims to synchronize their textures. I'd be wiling to pay some $L and my undying gratitude!
|
Jeff Otis
Registered User
Join date: 23 Aug 2004
Posts: 13
|
12-06-2004 14:58
I don't have time to fully explain it, but you will need:
1.) Add a llMessageLinked() (use an example from the wiki) as the person above me suggested.
2.) In the other script, within the LinkMessage (this is off the top of my head, name might be different) event, a check to see what the key is, and since I don't quite understand what you want the script to do, do whatever you need within an if statement seeing if the key is relevant (to make sure that you don't take ALL of the Namespace available).
You can see the wiki on the basics of how LinkedMessages work.
|
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
|
12-06-2004 16:37
in parent script after the llSetTexture line: llMessageLinked(LINK_SET,0,INVENTORY_TEXTURE,NULL_KEY); in the 'receiver' prim: default { link_message(integer sender,integer int,string texture,key id) { llSetTexture(ALL_SIDES,texture); } }
this way requires that you have a copy of the textures in both prims inventory. If they are all your textures or they are all copy/mod/transfer enabled you could use: llMessageLinked(LINK_SET,0,"",llGetInventoryKey(INVENTORY_TEXTURE)); and in the 'reciever' put: default { link_message(integer sender,integer int, string str,key texture); { llSetTexture(ALL_SIDES,texture); } }
Since llSetTexture can use a key without having the item in inventory this works without having to copy everything into the second prim... *but* you have to have full rights to get the key. Hope this helps, IM me if you need anything else. L8r, UU
|
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
|
12-06-2004 17:16
Here are two full scripts I wrote before seeing Upshaw's post above. it uses the second method he described, where you only need to put the texture into 1 prim, but you need full rights to the textures for it to work correctly. Create 2 prims, link them, and put the parent script into the parent, and the other script into the other prim. This way you can still drag textures onto the prim (while holding control) to add them. Parent Prim Script: float time = 0.5; //this is the time (in seconds)between texture changes. change it to anything you want
default { state_entry() { llSetText("",<1,1,1>,0); llSetTimerEvent(time); } timer() { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); //the total number of textures in inventory integer choice = (integer)llFrand(number); //randomly picks a number between 0 and the total above string name = llGetInventoryName(INVENTORY_TEXTURE, choice); //gets the name of the texture chosen key textureid = llGetInventoryKey(name); //gets the key of the texture chosen if (name != "") //not really needed. { llMessageLinked(LINK_SET,0,"",textureid); //sends a message with the textures key to the other prim(s). llSetTexture(name, ALL_SIDES); //set the texture. } }
on_rez (integer start_param) { llResetScript(); } } other prim script: default { link_message(integer sender_num, integer num, string str, key id) { llSetTexture(id, ALL_SIDES); //gets this message form the other prim and sets the texture //the key is used rather than the name as this way the texture only needs to be in the one prim's inventory that way. } }
|
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
|
12-06-2004 18:29
heh, thanks Rys, I never got a single A in my one and only high-school programming class (Turbo Pascal) because I never bothered to comment my code  I figured for sure someone would hit Submit Reply before I got finished as i was getting interrupted at work while trying to post it L8r, UU
|
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
|
12-06-2004 20:19
Hehe I've learnt to comment all my code because it helps the newbies and well they need all the help they can get (j/k). I learned LSL mostly by dissecting other peoples scripts and without comments it was pretty hard at times, hehe.
|
Wynx Whiplash
Registered User
Join date: 25 Sep 2004
Posts: 339
|
12-06-2004 20:31
From: Rysidian Rubio Hehe I've learnt to comment all my code because it helps the newbies and well they need all the help they can get (j/k). I learned LSL mostly by dissecting other peoples scripts and without comments it was pretty hard at times, hehe. Newbies like me??? Tee hee! It totally works. You all helped so much. Thank you, thank you, thank you!!!!!
|