Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Random animation script

Phoebe Cortes
Registered User
Join date: 2 May 2007
Posts: 2
03-03-2009 18:18
Hi - I've created a dance ball that works pretty well, except i can't work out how to add a "RANDOM" choice to the menu /prim so that the animations will randomly select. Can anyone help me with this please?
pheebs
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
03-03-2009 22:30
If the animations are in a list, pick a random number with
CODE

random = (integer)llFrand((float)(llGetListLength(list) + 1);


then:
CODE

animation = llList2String(list, random);


That should do it.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
03-03-2009 22:39
From: Ron Khondji
If the animations are in a list, pick a random number with
CODE

random = (integer)llFrand((float)(llGetListLength(list) + 1);



you can also do it without the list

integer num = llGetInventoryNumber(INVENTORY_ANIMATION);
random = (integer)llFrand(num + 1);

and i don't think you have to cast an integer into a float for uses within functions. the only problem i've had with not using a decimal is in particle scripts, it'll shout an error saying something like: PSYS_PART_MAX_AGE needs float data
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-03-2009 23:56
seeing as the 'random' variable is generated anew each time, why not just do away with it, and stick the random function in a call? unless you plan on reusing it to report which animation is being played.
_____________________
|
| . "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...
| -
Phoebe Cortes
Registered User
Join date: 2 May 2007
Posts: 2
thanks
03-07-2009 16:45
Will try these and see how i go. Will they also update the bluescreen menu and add in a RANDOM button? (that is what i was really trying to do - add this as an option within the danceball script)

Sorry if i sound like a gumby, but am very very new to scripting :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-07-2009 17:59
you'll need to add a button to your list that says "random", and detection of that choice in the listen to trigger the suggested code roughly
if ("random" == vStrSaid){
//-- or if ( 7 == llListFindList( gLstButtons, (list)vStrSaid ){ where 7 is the number of the menu button index for 'random'
//-- trigger code
}
_____________________
|
| . "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...
| -