Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multiple values from notecard?

Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
10-29-2005 22:59
Hello ive got a working one line notecard system.
I can change the value in the notecard and it changes the value in the script /
But in order for the dataserver to do anything ive been stuck putting in the
first line request into the state entry.
This is returning the first float from line one into the dataserver/
Now when I ettemp to request a new line the data in the datasever changes to this new
value.
I have placed a owner say in the data server and ive noticed that it says the first line and then says the next line ?

I want to say hey script read this line and give me that data and store it here/
And then read this line and store that data in a diff place?

I had first figured I could take the entire info from both lines and make it a list
and then just break them appart that way but I know there is a much more simpler
way and im just overlooking the simple im sure!
How is this done?

Any help would be awsome
Jenny Carlos
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-29-2005 23:10
When you read the lines, store the line number requested in a global variable. Then when you get the data in the dataserver event, use this line number to determinate which data it is you received ;)
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
Say What Lol
10-29-2005 23:26
You lost the hell out of me there/
Ive got it working for one value now.
Its just getting it to return value from line two and then store that one.
Example
A= data;
request new line
B = data;
Why is the data server seeming to change A to the new value when the second line
is requested.
A has been stored and the next line is being requested then B storeing data as the new data?

But its not quite working this way at all/ It seems to be a loop inside the dataserver tell the end of notecard is met.
Can I fool it to read first line save that data into A then get next line save that into B without changeing A?

Some working simple sample example that works would help me tons here lol.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-29-2005 23:34
From your answer I'm not sure what you are doing in your code... Are you calling llGetNotecardLine() again in the dataserver event then assume that the value of "data" changed to the other line's content without exiting the event and reentering it ? Because that's not how it works at all.

I'll need to see the code you're describing here.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
There is no working code thats why im posting lol
10-29-2005 23:52
So your saying create two dataserver events?

This code is very small and very simple im using/ in fact there is almost the same basic code example im using in my code now that is used for the lsl example for getting notecard info.

Can anyone show me how they are using the dataserver to get any two lines I wish from one notecard and then store those two values into two diff locations?

Im in game now if you just want to talk to me in game lol
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-30-2005 00:31
You can't have two different dataserver events. For it to act differently everytime it runs, it needs some external trigger, a way to determine what to do. That's what I mean with a global variable. First time it is called, the value is 0 and the data is stored in A; when it runs again the value is 1 and the data is stored in B.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
10-30-2005 00:32
Actually, if you're not going to be changing the data that you're reading off the notecard, a list is an easier and "faster" way of doing things. Reading a notecard calls the dataserver event...and the dataserver event is intensive.

Essentially you're lookin' for somethin' along the idea of (and the code is INCOMPLETE):

CODE


llGetNotecardLine(note, x)

dataserver(key id, string data)
{
do
{
if(x == 0)
{
stuff1 = data;
}
if(x == 1)
{
stuff2 = data;
}

//....etc.

x = x + 1;
llGetNotecardLine(note, x);
} while (data != EOF)
x = 0;
}

_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-30-2005 00:45
Err, Nilson, your example is not such a good example IMO. It calls the dataserver event total_lines - 1 times more than necessary :(

[Edit]
Woops, your code runs dataserver endlessly and only sets the first line :o I hope you don't use that in any real script.

Here's a fixed version:
CODE

line = 0;
llGetNotecardline(card, line);

...
dataserver(key query, string data)
{
if (data == EOF) return;
if (line == 0)
{
A = data;
} else if (line == 1)
{
B = data;
}
...
line = line + 1;
llGetNotecardLine(card, line);
}
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
10-30-2005 01:50
Hehe...sorry Jesrad...I just threw that out as a general concept in about 2 min...I should be a bit more careful though...


...thanks for the rescue.


[EDIT]

Wait...how do you figure that? The loop only exists so long as the data found on notecard line x isn't EOF...once it's EOF, the loop is broken and x reset to zero.

New lines are read with each increase in x...
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-30-2005 01:37
That's the tricky part: data is never refreshed within the do - while loop (a new dataserver event can't run until this one is done), so it keeps going and going like the proverbial bunny ;)
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
10-30-2005 01:53
Well then...there we go! Thanks for catchin' that.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
10-30-2005 02:55
Jesrad, in your example, does the a = a + 1 part (which I would simplify to ++a;) serve any purpose? Or was it just left in by mistake?

[edit]
Actually it looks like it should be ++line; is that correct?
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-30-2005 03:48
Yup, my bad :D I meant line = line + 1, thanks for pointing it out.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Jenny Carlos
Registered User
Join date: 30 Aug 2005
Posts: 52
Lol
10-30-2005 07:37
What have I created here lol
Anyway I now see code and this is good .
And yes the problem I was having was figuring out how to stop or close the event
and then start with a new line and not just loop from line to line.

I will play with the code here and see if this will work.
I was thinking last night of just putting this (USER DEFINED LOL) (WHY ELSE WOULD I WANT A NOTECARD LOL) notecard line into a list and then use the list to break it up.

Example

Use a incrementing notecard line into a list.
notecard example like below
test1/20
test2/50

Then using the first item in the list (test) as a control .
if test1 blah blah
if test2 blah blah

I would think this would work as ive put a simple sayowner in the loop and it will output
the changes for each line returned?
It should repeat to feed the list tell the end of the notecard is met correct?