TAHIRAH Pinkerton
Registered User
Join date: 27 Feb 2005
Posts: 4
|
07-17-2005 20:05
Hi guys just starting out scripting and finished a couple easy things thought I'd try this one on my own too with no success. So here I am to see if someone else might be able to help. Ok what I am trying to do is using the llFraud and llRound come up with a random number say between 1-3 and when that number is said on set channel it will say the text associated with that number. I know I need a listener to listen on set channel but what I have just isn't working. I know I probably have it all jacked up but Im going to try to post my code to see if anyone can look at it and figure out what I am doing wrong. Cause I can get it to say the first one but none of the rest. But it compiles fine weird. default { touch_start(integer total_number) { float FloatValue; integer IntValue; string StringValue; FloatValue =llFrand(2); IntValue = llRound(FloatValue); StringValue = (string)IntValue; llSay(1, StringValue); llListen(1,"","",""  ; if (IntValue==0) { llSay(0,"Am I working?"  ; if (IntValue==1) { llSay(0,"whatever"  ; if (IntValue==2) { llSay(0,"never says this"  ; } } } } }
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
07-17-2005 20:43
First of all, if you're using a listener, you might want to have a look at listen events.As for a text randomizer, one fun, efficient way to do it is as follows: list entries = ["One","Two","Three","Four","Five"]; // List your entries here
float test = llFrand(1); // Get a rand from 0 and 1. test *= llGetListLength(entries); // Multiply by number of entries. test -= 0.000001; // Prevents an error with a very low statistical chance.
llSay(0,llList2String(entries,(integer)test)); // Truncate the float to an integer as a test point. Very compact and easy to grasp once you know the functions. For more information: http://secondlife.com/badgeo/wakka.php?wakka=listshttp://secondlife.com/badgeo/wakka.php?wakka=llFrandhttp://secondlife.com/badgeo/wakka.php?wakka=llGetListLengthhttp://secondlife.com/badgeo/wakka.php?wakka=llList2String
_____________________
---
|
TAHIRAH Pinkerton
Registered User
Join date: 27 Feb 2005
Posts: 4
|
Thanks Jeffrey
07-17-2005 21:13
Works like a charm I knew there had to be an easier way to do it. And I have heard around that listeners aren't really all that good, that they cause lag n such. Does just what I need without the listeners yipee!! I am just beginning to understand little tid bits I have a long way to come and this is my first programming language but it's getting fun. Again thanks for your help
|