Difference between revisions of "Talk:LlGetNotecardLine"
m |
m (Replaced <lsl> with <syntaxhighlight>) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 55: | Line 55: | ||
|} | |} | ||
And the script: | And the script: | ||
< | <syntaxhighlight lang="lsl2">//Read multiple notecards back to the owner | ||
string notecard; | string notecard; | ||
key line_handle; | key line_handle; | ||
Line 83: | Line 83: | ||
} else { | } else { | ||
llOwnerSay((string)line + " = \"" + data +"\""); | llOwnerSay((string)line + " = \"" + data +"\""); | ||
line_handle = llGetNotecardLine(notecard, ++line); | |||
} | } | ||
} else if(id == length_handle) { | } else if(id == length_handle) { | ||
Line 91: | Line 91: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
I expect the output to be: | I expect the output to be: | ||
{| | {| | ||
Line 103: | Line 103: | ||
4 = "5" | 4 = "5" | ||
5 = "6" | 5 = "6" | ||
6 = "7"</pre> | 6 = "7" | ||
7 = EOF</pre> | |||
| | | | ||
<pre>Reading notecard: alternate | <pre>Reading notecard: alternate | ||
Line 113: | Line 114: | ||
4 = "5" | 4 = "5" | ||
5 = "" | 5 = "" | ||
6 = "7"</pre> | 6 = "7" | ||
7 = EOF</pre> | |||
|} | |} | ||
Please correct me if I'm wrong | Please correct me if I'm wrong | ||
-- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 14:16, 25 May 2009 (UTC) | -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 14:16, 25 May 2009 (UTC) | ||
<pre> | |||
[8:26] Object: Reading notecard: alternate | |||
[8:26] Object: Lines: 7 | |||
[8:26] Object: 0 = "1" | |||
[8:26] Object: 1 = "" | |||
[8:26] Object: 2 = "3" | |||
[8:26] Object: 3 = "" | |||
[8:26] Object: 4 = "5" | |||
[8:26] Object: 5 = "" | |||
[8:26] Object: 6 = "7" | |||
[8:26] Object: 7 = EOF | |||
[8:26] Object: Reading notecard: all | |||
[8:26] Object: Lines: 7 | |||
[8:26] Object: 0 = "1" | |||
[8:26] Object: 1 = "2" | |||
[8:26] Object: 2 = "3" | |||
[8:26] Object: 3 = "4" | |||
[8:26] Object: 4 = "5" | |||
[8:26] Object: 5 = "6" | |||
[8:26] Object: 6 = "7" | |||
[8:26] Object: 7 = EOF </pre> Was output. Yet more evidence that my scripts are rubbish and I should stop bothering people. I think when my script seemed to not count the blank lines as lines it prolly just needed resetting. Thanx for taking me seriously Strife but I am going quiet for a while till I have some idea what I am doing. -- '''[[User:EddyFragment Robonaught|Eddy]]''' 15:33, 25 May 2009 (UTC) |
Latest revision as of 01:52, 17 January 2024
Check validity of: "If the return is a NULL_KEY then notecard could not be found in inventory???". Check what happens if permissions are not present.
- I've checked it and it never return a NULL_KEY. Strife Onizuka 21:29, 16 April 2007 (PDT)
Does not support negative indexes
But....The first line is index "0" and strangely the last line is numbered as if the first line was "1".
Eg. llGetNumberOfNotecardLines() returns 6. Thus with line 0 being the first line , line 5 should be the last but this is not the case. Line 6 is the correct index for the last line. ???? -- Eddy 16:54, 24 May 2009 (UTC)
So if you had a notecard...
1 2 3 4 5 6
What is the value of associated with llGetNumberOfNotecardLines(notecard, 6)? Is the value "6" or EOF? -- Strife (talk|contribs) 17:40, 24 May 2009 (UTC)
Testing now. The reason I cannot say outright is that I have an if(data == EOF) change value of counter set up and am presently confused. However (it may take a little while to rebuild a test script(remember I am noob)) I set the counter to allow for the "0" index offset and it went to index-1 literal rather than the last index which was 6 in this case. So counter set to num_of_lines-1 returned 5 not 6. (I will remember to sign one day) -- Eddy 17:59, 24 May 2009 (UTC)
Whimper. Counter 5 gives line 6. But (this is why I whimper) linecount-1 did give line 5 not line 6 as you would imagine. I changed the script a few times since that wasn't working and can't remember exactly how it was. I think it might be best to put this down to scripter error and move on. Sorry. If there are 6 lines the last line is at index 5. But somehow(I will pay more attention in future) linecount-1 returned as if indexing started at 1 not o. -- Eddy 18:31, 24 May 2009 (UTC)
Do you think it's worth mentioning in caveats that if there is no info on a line it is not counted as a line? ie.
1 2 3 4 5 6
is still 6 lines and not 7. -- Eddy 18:53, 24 May 2009 (UTC)
Just discovered my error I think. I was setting count to linecount-1 then registering the function call with --count so calling 6-1 was then compounded with --count (slaps back of hand) obviously that returns 6-1-1. So there is nothing but scripter error and indexing is not malfuctioning. -- Eddy 19:50, 24 May 2009 (UTC)
It's hard for me to understand without looking at the script.
lets say we have two notecards:
1 ~ all 2 3 4 5 6 7 |
1 ~ alternate 3 5 7 |
And the script:
//Read multiple notecards back to the owner
string notecard;
key line_handle;
key length_handle;
integer line;
integer notecard_index = 0;
go() {
notecard = llGetInventoryName(INVENTORY_NOTECARD, --notecard_index);
llOwnerSay("Reading notecard: "+notecard);
length_handle = llGetNumberOfNotecardLines(notecard);
}
default {
state_entry() {
if(notecard_index = llGetInventoryNumber(INVENTORY_NOTECARD))
go();
else
llOwnerSay("Where's my notecard(s)?");
}
dataserver(key id, string data) {
if(id == line_handle) {
if(data == EOF) {
llOwnerSay((string)line + " = EOF");
if(notecard_index)
go();
} else {
llOwnerSay((string)line + " = \"" + data +"\"");
line_handle = llGetNotecardLine(notecard, ++line);
}
} else if(id == length_handle) {
llOwnerSay("Lines: " + data );
line_handle = llGetNotecardLine(notecard, line = 0);
}
}
}
I expect the output to be:
Reading notecard: all Lines: 7 0 = "1 ~ all" 1 = "2" 2 = "3" 3 = "4" 4 = "5" 5 = "6" 6 = "7" 7 = EOF |
Reading notecard: alternate Lines: 7 0 = "1 ~ alternate" 1 = "" 2 = "3" 3 = "" 4 = "5" 5 = "" 6 = "7" 7 = EOF |
Please correct me if I'm wrong -- Strife (talk|contribs) 14:16, 25 May 2009 (UTC)
[8:26] Object: Reading notecard: alternate [8:26] Object: Lines: 7 [8:26] Object: 0 = "1" [8:26] Object: 1 = "" [8:26] Object: 2 = "3" [8:26] Object: 3 = "" [8:26] Object: 4 = "5" [8:26] Object: 5 = "" [8:26] Object: 6 = "7" [8:26] Object: 7 = EOF [8:26] Object: Reading notecard: all [8:26] Object: Lines: 7 [8:26] Object: 0 = "1" [8:26] Object: 1 = "2" [8:26] Object: 2 = "3" [8:26] Object: 3 = "4" [8:26] Object: 4 = "5" [8:26] Object: 5 = "6" [8:26] Object: 6 = "7" [8:26] Object: 7 = EOF
Was output. Yet more evidence that my scripts are rubbish and I should stop bothering people. I think when my script seemed to not count the blank lines as lines it prolly just needed resetting. Thanx for taking me seriously Strife but I am going quiet for a while till I have some idea what I am doing. -- Eddy 15:33, 25 May 2009 (UTC)