I have a whisper text that works when you touch the prim. I need to be able to have the prim, when touched, whisper a random message.
string message = "Turn to the Left";
default
{
touch_start(integer total_number)
{
llWhisper(0, message);
}
}
These forums are CLOSED. Please visit the new forums HERE
Need Script to whisper random messages |
|
Lias Leandros
mainlander
![]() Join date: 20 Jul 2005
Posts: 3,458
|
06-01-2008 00:16
I have a whisper text that works when you touch the prim. I need to be able to have the prim, when touched, whisper a random message.
string message = "Turn to the Left"; default { touch_start(integer total_number) { llWhisper(0, message); } } _____________________
![]() http://slurl.com/secondlife/Bear/214/199/107 Join in SL open enrollment CLUB JOBS to announce new DJ and Host Jobs for free. And on Avatar's United http://www.avatarsunited.com/groups/club-jobs |
Eazel Allen
EA-design™
![]() Join date: 11 Feb 2007
Posts: 123
|
06-01-2008 00:43
Im not a great scripter myself but I adapted a question from a couple of posts down to answer yours I think this will work but havnt tested it yet.
CODE
UPDATE: tested it and it does work. ![]() _____________________
http://secondlife://cub/235/190/465/
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=48444 |
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
06-01-2008 09:42
Randomizing the whole list each time is overkill.
Generate a random integer instead, and then select taht item from the list. If you want random without replacement, then randomize the list once, and take the items in order. When you get to the end of the list, randomize the whole list again. _____________________
So many monkeys, so little Shakespeare.
|
Lias Leandros
mainlander
![]() Join date: 20 Jul 2005
Posts: 3,458
|
06-02-2008 09:55
Thanks fellas.
. _____________________
![]() http://slurl.com/secondlife/Bear/214/199/107 Join in SL open enrollment CLUB JOBS to announce new DJ and Host Jobs for free. And on Avatar's United http://www.avatarsunited.com/groups/club-jobs |
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
06-02-2008 10:34
Randomizing the whole list each time is overkill. Generate a random integer instead, and then select taht item from the list. If you want random without replacement, then randomize the list once, and take the items in order. When you get to the end of the list, randomize the whole list again. Yep... CODE
|
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
|
02-04-2009 21:06
Now how would you get this to read from a notecard?
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
02-04-2009 21:17
_____________________
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 |
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
|
02-04-2009 21:25
Was searching for days for that, don't no how i missed it, thanks
![]() |
Jesse Barnett
500,000 scoville units
![]() Join date: 21 May 2006
Posts: 4,160
|
02-05-2009 03:43
Randomizing the whole list each time is overkill. Generate a random integer instead, and then select taht item froom the list. If you want random without replacement, then randomize the list once, and take the items in order. When you get to the end of the list, randomize the whole list again. Still more efficient to just keep generating the random number and not use llRandomizeList at all, especially as the list length grows. EDIT: I was putting the reference here but I see Ruthven beat me to the punch. _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
Paladin Pinion
The other one of 10
Join date: 3 Aug 2007
Posts: 191
|
02-06-2009 19:01
This line is interesting, I never thought to do it this way:
messageNumber = (integer)llFrand((float)llGetListLength(message)); It looks like this would never retrieve the final (total) numbered mesage item. Is that right? I've been using llFloor or llCeil to get integers afer randomizing. |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
02-06-2009 21:42
llFrand picks a random number between 0 and the number given. in this case it's the length of the list. however, if it does happen to pick that length, it will return an empty string because the list indexes start at 0
so basically if you have a list of 24 messages, you would actually want to do something like this so it picks a random number between 0 and 23, because 23 will be the index for the last message integer len = llGetListLength(messages); integer index = (integer)llFrand(len-1);//minus the length by 1 so that it will be a random number between 0 and the last index instead of the length llWhisper(0,llList2String(messages,index)); _____________________
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 |
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
02-07-2009 17:20
Yes, sorry, that was a mistake. It works, but it should be length-1.
_____________________
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
02-08-2009 01:21
llFrand(max) generates a number between 0.0 and max.
This means max is not included. Casting the generated float to a integer leaves you with the greatest integer smaller than the float. The highest integer you an get from llFrand(5.0) = 4 In other words: there's no need for the -1. This is from the wiki: llFrand(); generates a random number, between 0.000000 and the preset float minus 0.000001. Example : llFrand(2); will generate a float between 0.000000 (this one included) and 1.999999. So 2.000000 is NOT included !!! I ran a test and uses llFrand 215,000,000 times to check out. --Jody Palmer-- |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
02-08-2009 06:57
yep, thought about that last night ron. probably why they paladin mentioned llFloor, but that floats down so it's still gonna give the same result as casting it to an integer. using llRound will round it to the nearest, up or down. so it could be:
integer index = llRound(llFrand(len-1)); _____________________
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 |