These forums are CLOSED. Please visit the new forums HERE
Reading from Notecard |
|
|
Adiana Lazarno
Registered User
Join date: 30 Mar 2006
Posts: 5
|
03-19-2009 20:48
So I've been playing with talking objects and have gotten the hang of simple actions. Now I'm wanting to figure out how to get my object to read from a notecard with multiple responses and messages. Also, is there anyway to get the object to listen for key words instead of an exact phrase. Thanks so much everyone...The earlier info was very helpful!
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
03-19-2009 21:13
So I've been playing with talking objects and have gotten the hang of simple actions. Now I'm wanting to figure out how to get my object to read from a notecard with multiple responses and messages. Also, is there anyway to get the object to listen for key words instead of an exact phrase. Thanks so much everyone...The earlier info was very helpful! Try working your way through this very nice tutorial .... |
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
03-19-2009 21:30
So I've been playing with talking objects and have gotten the hang of simple actions. Now I'm wanting to figure out how to get my object to read from a notecard with multiple responses and messages. Also, is there anyway to get the object to listen for key words instead of an exact phrase. Thanks so much everyone...The earlier info was very helpful! Well for starters, look here to see how to trigger a data_server event to read a notecard: http://wiki.secondlife.com/wiki/LlGetNotecardLine As far as listens are concerned.... CODE
Where msg is a string you're testing for... CODE
will listen for any avatar or object (first set of quotes), any key, and any message triggers the listen event. whereas: CODE
will only trigger a listen event if rosebud is heard. That said... now... If you're looking to 'pick out' a catchphrase from some chat, i.e. 'duck' is the magic word, so if an avatar says, "I went duck hunting last weekend", you'll want ot use llSubStringIndex() for that.... In that case, for the listen function, you'd listen for all chat... CODE
and your listen event would look like this... CODE
Basically, llSubStringIndex() returns a negative 1 if the string is not found, if it does, it sets the test variable to the position of the first charcater in the message string. Hope that helps... _____________________
My tutes
http://www.youtube.com/johanlaurasia |
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
03-20-2009 20:11
Notecards can be read via the llGetNotecardLine function. Note that the function doesn't return the actual text from the notecard, but rather a UUID that can be used to retrieve the text in the dataserver event.
A basic notecard reader would look something like this: integer NoteLine; key NoteKey; string text; default { state_entry() { llSetText("Reading notecard, please wait...", <1.0,1.0,0.0>, 1.0); text = ""; NoteLine = 0; NoteKey = llGetNotecardLine("My Notecard", NoteLine); } dataserver(key QueryID, string data) { if (QueryID == NoteKey) { if (data != EOF) { text += data + "\n"; NoteLine ++; NoteKey = llGetNotecardLine("My Notecard", NoteLine); } else { llSetText(text, <0.0,1.0,0.0>, 1.0); } } } } That script hasn't been compiled yet, so please excuse any typos I might have made. I hope this helps. --Cypher _____________________
Life is a highway... And I just missed my exit.
|