|
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
|
05-15-2007 12:07
I am using this portion of a script here... I have gotten this portion from another script in which i have changed here and there. key avatar = ""; // Avatar key here
//variables removed
string gName = "zOwner";
//Script removed
init() { if (gName != "") // if a notecard is found avatar = (key)llGetNotecardLine(gName, 1); // request first notecard line else llOwnerSay("No Owner Notecard Located");
llSensorRepeat(name, avatar, AGENT, 100, TWO_PI, time); // Fire up the sensor searching = 1; timeout = 0; found = 0; llSetTimerEvent(2); }
Now the issue that I am having is that the first line of the notecard is read and placed into 'avatar', but whenever I attempt to use this key in any function it does not work. However If I comment out the 'avatar =' line and place the key I want into where the key is called, it works just fine. Now in the notecard I do not have the key that I am pulling in quotes. I don't think that this would be much on an issue since it is not a string. Any ideas what would be causing this?
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
05-15-2007 12:18
llGetNotecardLine() From: someone This function fetches line number of notecard name and returns the data through the dataserver event. The line count starts at zero. If the requested line is past the end of the notecard, the dataserver event will return the constant EOF ("End Of File"  string. You can get the number of lines in a notecard with llGetNumberOfNotecardLines. The key returned by llGetNotecardLine is a unique identifier which will be supplied to the dataserver event as the queryid parameter. In short, start with 0. key avatar = ""; // Avatar key here
//variables removed
string gName = "zOwner";
//Script removed
init() { if (gName != "") // if a notecard is found avatar = (key)llGetNotecardLine(gName, 0); // Now it actually does request first notecard line else llOwnerSay("No Owner Notecard Located");
llSensorRepeat(name, avatar, AGENT, 100, TWO_PI, time); // Fire up the sensor searching = 1; timeout = 0; found = 0; llSetTimerEvent(2); }
|
|
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
|
05-15-2007 12:23
Hmmm.... I definately understand that now. But why was it pulling the first line already. Was is also pulling the EOF and this caused the information pulled to not be a key?
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
05-15-2007 13:10
Are you positive that it was reading in the first line? You had it llOwnerSay it or something?
|
|
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
|
05-15-2007 13:58
I am not looking at it right now, due to RL working  , but I do beleive it was was storing the key but just not implementing it. However I do want to try the 0 for the line number. I will try this once i get home.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-15-2007 14:11
The line before the one Milambus highlighted is the (next) important one - llGetNotcardLine function starts a database query and returns a key to the query id. It doesn't return the notecard line itself. You'll need to use the dataserver event to get the actual contents of the line.
There's a simple code sample on the wiki page..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-15-2007 15:49
Yep, all you are getting there is the key that references the dataserver event, rather than the notecard line. Add in a dataserver event, and get the key from there: key nline; nline=llGetNotecardLine(gName, 0); dataserver(key queryid, string data){ if(queryid==nline){ avatar=(key)data; } }
You'll have to do that in a state rather than a function though, as a function cannot hold the dataserver event.
_____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|