Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
|
03-26-2005 10:19
Hi There,
I'm looking for a script that will allow me to place multiple animations into an object replacing the 'Touch' Dial with 'Select Animation'. Once the animation is selected it should be usable through the 'Sit' dial.
I have tried to make this script, but I was unable to get it working. (I'm not a very good scripter).
Thanks in advance.
xoxo
Storma
|
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
|
03-26-2005 11:28
Umm lets see...
Well when I get home I can post some code that will do this and support as many animations inside is as you can fit. Ill post it here in about an hour when I get home.
Well it doesnt change the animation when you sit on it though.
|
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
|
Heres half of what you wanted.
03-26-2005 13:35
Okaay, as promised heres half of what you want... Im not really up to programming the whole thing for you... Its always good to learn  (and always remember its good to give credit where credit is due) list myList; //List of all anims inside list myStride; //List of current items displayed integer num; //A Number string myAnim; //Selected animation
default { state_entry() { llSetTouchText("Pick Animation"); myList = []; } touch_start(integer detect) { if(llDetectedKey(0) == llGetOwner()) state Chooser; } }
state Chooser { state_entry() { integer total = llGetInventoryNumber(INVENTORY_ANIMATION); //How many do we have? integer i = 0; //Counting integer llListen(34054,"",llGetOwner(),""); //Create Listener for Dialogue box if(myList == []) { num = 0; do { myList += llGetInventoryName(INVENTORY_ANIMATION, i); i++; } while(i < total); } if(total - (num * 9) >= 9) { myStride = llList2List(myList, num * 9, ((num + 1) * 9) - 1); //Create list of objects if more then 9 total } else { myStride = llList2List(myList, num * 9, (num * 9) + (total % 9)); //Create list if less then 9 items left } llDialog(llGetOwner(), "\t\t\t\t\t Choos Animation \n\n\n Current animation : " + myAnim,["Prev","Next","Back"] + myStride,34054); llSetTimerEvent(30.0); //Timeout timer (change if you want a shoreter or longer timeout. } listen(integer chan, string name, key ID, string msg) { if(msg == "Prev") { if(num >= 1) num--; //If on a page other then one, goto the previous page state retChooser; } else if(msg == "Next") { if(llGetInventoryNumber(INVENTORY_ANIMATION) - (num * 9) > 9) num++; //If more items available, goto the next page. state retChooser; } else if(msg == "Back") //Return to the start of the program if back selected { myList = []; state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } else //Return to the start of the program when a new anim is choosen { myAnim = msg; myList = []; state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } } timer() //Timer to timeout if nothing is done within 30 seconds. { llSetTimerEvent(0.0); myList = []; state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } touch_start(integer count) { if(llDetectedKey(0) == llGetOwner()) //If owner touches automatically go back to the normal state. { state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } } state_exit() { llSetTimerEvent(0.0); //Probably not needed, but resets the timer } }
state retChooser { state_entry() { state Chooser;}} Anyone who would like to use this feel free, you can just change a few pieces here and there to make it work for any object in an objects inventory.
|
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
|
03-26-2005 17:03
Thank-you so, so much Talia - I'll give it try *smiles*
|
Storma Amarula
Registered User
Join date: 8 Mar 2005
Posts: 87
|
03-26-2005 18:04
Hi - everything works great, but is there a way the script (object) can remember the last animation picked? The way the script works now, the user must rechoose the animation if they stand.
For example, if the first animation on the list was chosen and the person left, could the next person just start the animatio nwithout having to choose again?
Thanks,
Storma
|
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
|
03-27-2005 00:09
... string myAnim; //Selected animation ... Should save the animation, unless the script is totally reset. so you shouldnt have to rechoose the anim every time. I could also edit it so the script changes the object description, so if you have to reset the script, you could load it off of object description. In fact, heres what you do to do that. just add this call llSetObjectDesc(msg); Into this else statement, before the line saying state default; ... else //Return to the start of the program when a new anim is choosen { myAnim = msg; //<--- Add After this Line myList = []; state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } ...
to look like this ... else //Return to the start of the program when a new anim is choosen { myAnim = msg; //Save current animation to global string. llSetObjectDesc(msg); //Set object description to current animation. myList = []; state default; //Change default if you have a different waiting state(recomended if you reset variables in default) } ...
and then use llGetObjectDesc() to Load your animation name for playing. LSL Wiki llGetObjectDesc()
|