|
Allan Monday
Registered User
Join date: 29 Jan 2009
Posts: 17
|
04-01-2009 19:10
I tried something, and it didn't work. Now i dont understand where my problem so if anyone has time to look at this and tell me what I did wrong, so I can learn from my mistakes it would be greatlt appreciated. float gIng; default { state_entry() { llGetNumberOfNotecardLines("grumble_card"  ; } dataserver(key queriID, string data) { float gIng = (float) data; } touch_start(integer n) { state pizza; } } state pizza{ state_entry() { llGetNotecardLine("list", llFrand(gIng) +1 ) ; } dataserver(key id, string data) { llSay(0, data); } }
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
04-01-2009 22:22
You declared gIng twice. First as a global and then as only in the default state dataserver event. There's nothing to check if the data from the dataserver is the data you requested. For this you need something like query = llGetNotecardLines(), and in the dataserver: if (queryID == query){ etc. You also have nothing to go back to the default state. Read these: http://wiki.secondlife.com/wiki/LSL_Variableshttp://wiki.secondlife.com/wiki/Dataserverhttp://wiki.secondlife.com/wiki/StateThis is how I would have tried it: float gIng; key query_linenums; key query_line;
default { state_entry() { query_linenums= llGetNumberOfNotecardLines("grumble_card"); }
touch_start(integer n) { query_line = llGetNotecardLine("grumble_card", (integer)(llFrand(gIng)) +1 ) ; }
dataserver(key queryID, string data) { if (query_linenums == queryID) gIng = (float) data; else if (query_line == queryID) llSay(0, data); } }
|
|
Allan Monday
Registered User
Join date: 29 Jan 2009
Posts: 17
|
04-01-2009 22:36
Ahh can see clearly now, the thing i couldnt understan was how to get the data out of the llGetNumberOfNotecardLines and the data out of the llGetNotecardLine in the same state. So what i do is testing which data it is , the dataserver event has for me right? Now i know where my mistake was. Thank you very much for your Help
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-02-2009 05:47
and if you want it to go faster and work more reliably, you can read the whole notecard into a list and then randomly pick your phrases from the list
get note line is kinda like a stupid intern... you tell it fetch you a report (the line from your notecard) and instead of bringing it to you (in the event you called it from), it drops it in your office inbox (the dataserver event)... sometimes the intern gets lost on the way and forgets, or stops for coffee... he isn't always reliable that way.
to continue the analogy, to get him to continuously bring you reports in order, start by sending him for the first one, then meet him at the inbox and send him for the next one (by incrementing a global counter), repeating the second action until he says there nothing left to bring (EOF == data). you can do anything you want to those reports in your inbox when you get them that how you read in an entire notecard.
_____________________
| | . "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... | - 
|