Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

linking a button

Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 10:22
hello. im fairly new to LSL so i might have alot of noob question.. for that im sorry.. but im trying to get a button thats linked to another prim to whre, when you click it, the root prim sscript loads up a notecard. (just for your info im makingyet another texture organizer.)
CODE

string current_notecard;
integer current_block;
integer DISPLAYS = 15;
string alpha_empty = "textdump: (UnAvailable,029776c4-ab67-5072-79d6-d54f91e2aec2)";
integer line_in_block;
key QID;
integer notecard_entries;
integer categories;
list category_list;
key QID_lines;

load_notecard_block()
{
line_in_block = 0;
QID = llGetNotecardLine(current_notecard, current_block * DISPLAYS + line_in_block);
}

category_load()
{
integer i;
categories=0;
category_list = [];

for(i=0; i<= -1 + llGetInventoryNumber(INVENTORY_NOTECARD);i++)
{

if(llGetInventoryName(INVENTORY_NOTECARD,i) != "GNU License"
&& llGetInventoryName(INVENTORY_NOTECARD,i) != "YATO-BF Readme")
{
category_list += [llGetInventoryName(INVENTORY_NOTECARD,i)];
categories++;
}

}
}
default
{
state_entry()
{
integer i;

llSensor("",llGetOwner(),AGENT,20,PI);
current_notecard = "";
current_block = 0;

for(i=0;i<=DISPLAYS;i++) {
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)i+" "+alpha_empty, NULL_KEY);
}

category_load();
}

on_rez(integer n) {
llResetScript();
}

changed(integer n) {

if(n == CHANGED_INVENTORY)
category_load();

}
link_message(integer sender_number, integer number, string msg, key id)
{
if(msg == "rock")
{
category_load();
return;
}
if(msg == "back" && current_block > 0)
{
current_block--;
return;
}
if(msg == "next" && current_block < 0)
{
current_block++;
return;
}
if(llSubStringIndex(msg,"large_panel") == 0)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, msg, NULL_KEY);
}
}
dataserver(key queryid, string data)
{
if(queryid == QID_lines)
{
notecard_entries = (integer)data;
current_block = 0;
line_in_block = 0;
load_notecard_block();
}

if(queryid == QID)
{
if(data != EOF)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)line_in_block+" "+data, NULL_KEY);
line_in_block++;

if(line_in_block <= DISPLAYS)
QID = llGetNotecardLine(current_notecard, current_block * DISPLAYS + (line_in_block));

}
else
{

for(;line_in_block<=DISPLAYS;line_in_block++)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)line_in_block+" "+alpha_empty, NULL_KEY);
}
}
}
}

sensor(integer keynum) {
vector pos=llDetectedPos(0);

llLookAt(pos,.5,.5);
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 10:52
So all you need to do is add a touch_start event that looks something like this..

CODE

touch_start(integer num)
{
integer WhichPrim = llDetectedLinkNumber(0);
if (WhichPrim == 2) // Or whatever the link number for your button prim is....
{
load_notecard_block();
}
}


or words to that effect. The important thing is that llDetectedLinkNumber will tell you which part of the linkset was just touched. Once you know that, you can go ahead and do whatever it is that the touch was supposed to activate.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 11:02
so i should be able to do that with multiple buttons the way you have it written correct?
cause i have multiple buttons and each one is going to load up a diffrent notecard.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 12:25
Yup. So long as each button is a different link in the linkset, all you have to know is which link number it is. Then you just start stacking up if tests.....

CODE

if (WhichPrim == 2)
{
// Do whatever button #1 does
}
else if (WhichPrim == 3)
{
// Do whatever button #2 does
}
else if (WhichPrim == 4)
.
.
.
// And so forth.


llDetectedLinkNumber identifies the prims in the reverse order in which they were added to the linkset, so #1 (root prim) was the last prim added, #2 was the next to last, and so on. If you use this method, you don't need to put an extra script in each button. Put everything in a single script in the root prim and let llDetectedLinkNumber tell you which part of the code sequence to execute when someone touches one of the buttons.

You will have to be a wee bit careful with your various calls to llGetNotecardLine, to be sure that the dataserver is looking at the right line on the proper card each time someone clicks a different button, but that's just fiddly stuff.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 12:37
ok now i dont know if its the script or what but its not showing the texture i have already in one of the notecards on the smaller display. :|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 13:46
Time for detective work. ;) That's the fiddly stuff I mentioned earlier. Be careful to check that you are calling the right line on the right notecard when you execute a llGetNotecardLine request to the dataserver. Pepper the script with llOwnerSay statements to tell you what is actually happening each time you read a notecard. It's really easy to mess up on the index of a loop somewhere and call something you didn't expect. I do it all the time. :p
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 13:51
*crosses my eyes and starts looking in my dictonary to find some english phrases in there*
in my defence i did say i was a noob at this.. lol
is there a way to dumb it down for me a bit please?
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 14:46
ok i got to reading your post over again a few times and i think i might understand. but im also not sure i put the section of the script in the right place. idk

CODE

// Copyright (C) 2009 Zaine Swords (RZ Builders)

string current_notecard;
integer current_block;
integer DISPLAYS = 19;
string alpha_empty = "textdump: (UnAvailable 2,0ef456eb-10a3-3ff7-7356-a9f6f7d2de7f)";
integer line_in_block;
key QID;
integer notecard_entries;
integer categories;
list category_list;
key QID_lines;

load_notecard_block()
{
line_in_block = 0;
QID = llGetNotecardLine(current_notecard, current_block * DISPLAYS + line_in_block);
}

category_load()
{
integer i;
categories=0;
category_list = [];

for(i=0; i<= -1 + llGetInventoryNumber(INVENTORY_NOTECARD);i++)
{

if(llGetInventoryName(INVENTORY_NOTECARD,i) != "GNU License"
&& llGetInventoryName(INVENTORY_NOTECARD,i) != "YATO-BF Readme")
{
category_list += [llGetInventoryName(INVENTORY_NOTECARD,i)];
categories++;
}

}
}
default
{
state_entry()
{
integer i;

llSensor("",llGetOwner(),AGENT,20,PI);
current_notecard = "";
current_block = 0;

for(i=0;i<=DISPLAYS;i++) {
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)i+" "+alpha_empty, NULL_KEY);
}

category_load();
}

touch_start(integer num)
{
integer WhichPrim = llDetectedLinkNumber(0);
{
if (WhichPrim == 3)
{
llGetNotecardLine("rock", 0);
}
else if (WhichPrim == 4)
{
llGetNotecardLine("tile", 0);
}

load_notecard_block();
}
}


on_rez(integer n) {
llResetScript();
}

changed(integer n) {

if(n == CHANGED_INVENTORY)
category_load();

}
link_message(integer sender_number, integer number, string msg, key id)
{

if(msg == "back" && current_block > 0)
{
current_block--;
return;
}
if(msg == "next" && current_block < 0)
{
current_block++;
return;
}
if(llSubStringIndex(msg,"large_panel") == 0)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, msg, NULL_KEY);
}
}
dataserver(key queryid, string data)
{
if(queryid == QID_lines)
{
notecard_entries = (integer)data;
current_block = 0;
line_in_block = 0;
load_notecard_block();
}

if(queryid == QID)
{
if(data != EOF)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)line_in_block+" "+data, NULL_KEY);
line_in_block++;

if(line_in_block <= DISPLAYS)
QID = llGetNotecardLine(current_notecard, current_block * DISPLAYS + (line_in_block));

}
else
{

for(;line_in_block<=DISPLAYS;line_in_block++)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "single_view"+(string)line_in_block+" "+alpha_empty, NULL_KEY);
}
}
}
}

sensor(integer keynum) {
vector pos=llDetectedPos(0);

llLookAt(pos,0,0);
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 15:04
Uh-oh.... OK... When you are troubleshooting a script, you usually need some way to find out what is actually happening at potential trouble spots. You can reach into the script and see by using llOwnerSay. (Take a look at http://lslwiki.net/lslwiki/wakka.php?wakka=llOwnerSay.) For example, at a few places in the script you have a line starting with QID= that is triggering the dataserver to read from a notecard. If you want to find out which notecard the dataserver is going to read, then insert the following line immediately after the QID= line .....

llOwnerSay( "The current notecard is " + current_notecard);

When you test the script, this message may tell you that it's reading the wrong card, in which case you know where you have to fiddle to get it to read the right one. If that's not the problem, try a llOwnerSay in another spot. Don't do this blindly, of course. Think your way through the script and map out the path it follows as it executes to figure out where things are likely to go wrong.

You picked a fairly complicated script to work on as a beginner, but if you can lick it you will have learned a lot.

ETA: Um... hold on... You posted something while I was typing this ..... to be continued ....
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 15:07
well i only have one notecard in the script right now. but i will put that in the script anyways..
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 16:04
ok i inserted the llOwnerSay aas you suggested (btw the website link you sent me didnt work) and its not telling me if a notecard is being read or what notecard is being read so it seems to me that either the button or somewhere in the main script which i have posted, isnt working properly.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 16:04
OK...... Where to start?....... :o Forget what I just posted regarding diagnostic llOwnerSay statements. There's more serious stuff to work on, and your script is not at the point of needing that sort of diagnostics yet.

Let's look at what a dataserver event does. Basically, it's a way for the script to get data from some outside source ... a web server, one of LL's own servers, or maybe a notecard. You have to trigger the dataserver event by giving it a specific request that tells it where to look and what to look for. Each request yields one bit of data (the "data" parameter in the dataserver event statement).

When you want information from a notecard, you write ....

integer ID = llGetNotecardLine(notecardname, linenumber);

The ID is a "serial number" of sorts so that the dataserver can keep track of that specific request among many others that you may also make.

I suggest that you read through and maybe the tutorial at to get a feel for how this works. It's not easy stuff to get your head around at first, but it really does make sense. I think that as you study that material you'll start to see why your latest posted script isn't going to work as you hoped. Among other things, I think you'll find, as I did, that your script never says exactly what value the variable "current_notecard" has after it is initially set to "", so you're never telling the dataserver which card to read.

Now, what to do next ....? Frankly, I think it will be easiest to rebuild the script from scratch. What you have done already gets information from scripts that are supposed to be placed in other prims in the linkset (your buttons), but its logic is very hard to follow, and it doesn't have any provision for telling which notecard to look at. You could certainly build a working script that uses llMessageLinked, but it's going to take a lot of effort to get this one to do it.

When I suggested using llDetectedLinkNumber, it was a way to simplify things by replacing the link_message event with a touch_start event that puts everything into a single script instead of passing information back and forth among many scripts in the linkset. Although I think that will be a much easier script to write and understand, I 'm afraid that I have actually confused you by suggesting it. Whatever you do at this point will involve some work.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 17:57
ok. i went though those 2 sites you sent me to.. they were of some help. i rewrote the script, keeping SOME of the vital things i needed, like the dataserve portion. but, i go to save the script i get a syntax error at (59,0). the begining of the dataserver section. i dont see where i messed up so if you could point out where i goofed that would be great.. thanks again though for all your help. you'v been great.

CODE

string rock = "rock";
string view_text= "(UnAvailable,0ef456eb-10a3-3ff7-7356-a9f6f7d2de7f)";

integer display = 19;
integer line_in_blcok;
integer notecard_entries;
integer category;
integer current_block;

key noteid;
key idnote;

load_block()
{
line_in_block = 0;
idnote = llGetNotecardLine(category, current_block *display + line_in_block);
}

default
{
state_entry()
{
integer v;

for(v=0;v<=display;v++)

llMessageLinked(LINK_ALL_CHILDREN,0,"single_view"+(string)v+" "+view_text, NULL_KEY);
}

touch_start(integer num)
{
integer button = llDetectedLinkNumber(0);
{
if (button == 3)
{
llGetNotecardLine("rock",0);
}
else if (button == 4)
{
llGetNotecardLine("tile",0);
}
else if (button == 20)
{
current_block--;
}
else if (button == 21)
{
current_block++;
}
}
}

on_rez(integer start_param)
{
llResetScript();
}

}

dataserver(key id, string data)
{
if (id == noteid)
{
notecard_entries = (integer)data;
current_block = 0;
line_in_block = 0;
load_block();
}
if (id == idnote)
{
if(data != EOF)
{
llMessageLinked((LINK_ALL_CHILDREN, 0, "single_view"+(string)line_in_block+" "+data, NULL_KEY);
}
else
{
for);line_in_block<=display;line_in_block++)
{
llMessageLinked((LINK_ALL_CHILDREN, o, "single_view"+(string)line_in_block+" "view_text, NULL_KEY);
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-31-2009 18:35
for);

and the data_server event is outside the state among many other problems.

"Life is like a box of chocolates!" ooops wait, wrong metaphor. "LSL is like an Onion" built of many layers. You still od not have it broke down into the constituent parts.

Create a script using llDetectedLinkNumber and llOwnerSay that each one returns the right button. Make sure this script works.

Create another script doing nothing but reading a single notecard and make sure it works.

Now take the notecard reading and add it to the first script and make sure that when you push button one, it will read that notecard.

Now add in complexity. Make it read one notecard with button one and another notecard with button two etc.

Check and keep checking one part at a time and make sure it works before adding the next layer.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 18:39
ok i noticed alot of errors in it so i managed to get them fixed but im still coming up with the same problem as i was before. appearntly i didnt understand that tutorial as much as i thought i did. :| here is the updated script to it now.

CODE

string rock = "rock";
string tile = "tile";
string current_notecard;
string view_text= "(UnAvailable,423aa8ff-975d-12ed-dbd7-eb5a21cdfbd1)";

integer display = 19;
integer line_in_block;
integer notecard_entries;
integer category;
integer current_block;

key noteid;
key idnote;

load_block()
{
line_in_block = 0;
idnote = llGetNotecardLine(current_notecard, current_block * display + line_in_block);
llOwnerSay("
}

default
{
state_entry()
{
integer v;

for(v=0;v<=display;v++)

llMessageLinked(LINK_ALL_CHILDREN,0,"single_view"+(string)v+" "+view_text, NULL_KEY);
}

touch_start(integer num)
{
integer button = llDetectedLinkNumber(0);
{
if (button == 3)
{
llGetNotecardLine("rock",0);
}
else if (button == 4)
{
llGetNotecardLine("tile",0);
}
else if (button == 20)
{
current_block--;
}
else if (button == 21)
{
current_block++;
}
}
}

on_rez(integer start_param)
{
llResetScript();
}



dataserver(key id, string data)
{
if (id == noteid)
{
notecard_entries = (integer)data;
current_block = 0;
line_in_block = 0;
load_block();
}
if (id == idnote)
{
if(data != EOF)
{
llMessageLinked(LINK_ALL_CHILDREN,0, "single_view"+(string)line_in_block+" "+data, NULL_KEY);
}
else
{
for(;line_in_block<=display;line_in_block++)
{
llMessageLinked(LINK_ALL_CHILDREN,0, "single_view"+(string)line_in_block+ "view_text", NULL_KEY);
}
}
}
}
}
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
10-31-2009 18:58
If you name the child prims based on function, you can use llGetLinkName (llDetectedLinkNumber(0)); ...
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- 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
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 19:01
Keep at it. I told you this was a challenging script for you to learn on, but it is actually looking better. That little problem you are having is actually a small one. As Jesse pointed out, you have an extra closed curly bracket, "}" right before the dataserver event. That makes the default state end right there, so the dataserver event is ignored.

Are you using the LSL Editor, by any chance. If not, give it a try. It can have two advantages. One is that you can at least write and test your snytax outside of SL. The other is that the LSL Editor has fairly helpful diagnostic error messages, so it's easier to spot what's wrong.

Now... check the spelling ( and capitalization) of all variables in your script. You have one named "noteid," for example, but it's called "idnote" in another spot. Won't fly.

Also look at ALL of your llGetNotecardLines statements, not just one of them. Each one triggers a dataserver event, so each one needs to have an id that the dataserver event can grab onto. (That's the "noteid" or "idnote" variable :) ).

And what Jesse said....... for(; won't work either.

Jesse actually gave you the best piece of advice yet. Especially when you are learning, try building the script in pieces and THEN glue them together. Give it a shot.

You're getting better at this already.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 19:30
ok. i belive i took out that extra } before the dataserver. if you look at the top of the script "note id" and "idnote" are 2 diffrent variables.i know they look like there the same but they arnt. i made sure i used them in 2 diffrent ways. as for Jesse i didnt know he added onto his last post, i just got done reading it. last thing i saw on his poast for "for(;" :P but i will go back to the script and see what i cant do. thank you all for all your help. im sure i will be posting more on this at a later time. prolly sometime later tonight.

ETA: Yes i do use LOSL Editor. find that to be a good program so ty :)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-31-2009 21:11
From: Zaine Swords
ok. i belive i took out that extra } before the dataserver. if you look at the top of the script "note id" and "idnote" are 2 diffrent variables.i know they look like there the same but they arnt. i made sure i used them in 2 diffrent ways. as for Jesse i didnt know he added onto his last post, i just got done reading it. last thing i saw on his poast for "for(;" :P but i will go back to the script and see what i cant do. thank you all for all your help. im sure i will be posting more on this at a later time. prolly sometime later tonight.

ETA: Yes i do use LOSL Editor. find that to be a good program so ty :)

Ah... but you don't need two variables. That's the point. Each time you trigger the dataserver event that variable (whichever one you use) takes a different value. That's all the dataserver cares about.

Now... Do go back and look at all the other llGetNotecardLines calls. Most of them will not trigger a dataserver event.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 21:19
i am in the middle of rewriting the script for the 3rd time.. lol but im taking Jesse's advice and building it into 3 parts this time. i got the buttons to worked with llDetectedLinkNumber(0) with the llOwnerSay. it worked great. now im in the middle of working on it getting to read the notecards.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-31-2009 21:41
From: Zaine Swords
i am in the middle of rewriting the script for the 3rd time.. lol but im taking Jesse's advice and building it into 3 parts this time. i got the buttons to worked with llDetectedLinkNumber(0) with the llOwnerSay. it worked great. now im in the middle of working on it getting to read the notecards.

YAY!!!!!!

This is a huge step and will help you tremendously from now on. I am not the smartest coder on the block, I am just extra hard headed and I learned that trick. A few languages later and I still break it down to easy to understand parts first and then assemble my final code.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
10-31-2009 22:09
From: Jesse Barnett
I am not the smartest coder on the block...

Hey! Don't be modest - you can write with the best of 'em, Jesse!
From: Jesse Barnett
I am just extra hard headed..

Well, ok. I'll give you that one. :)

(and I still say to use llGetLinkName(llDetectedLinkNumber(0)).. just you wait until you touch the link set and it all gets renumbered in some seemingly random order!)
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- 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
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
10-31-2009 22:09
ok, im working on the notecard reader and i took the basic multicard reader script and edited it for my own use. i have all the notecards in there and the script compiled with no errors in LSL and in SL. but in SL its saying it cant find notecard ". and thats all i get. where did i goof?

CODE

list text1; // All the lines from from the first card
list text2;
list text3;
list text4;
list text5;
list text6;
list text7;
list text8;
list text9;
list text10;
list text11;
list text12;
list text13;
list text14;
list text15;
list text16;

string card1 = "Rock"; //Set these to the name of the inventory item.
string card2 = "Tile";
string card3 = "Stone";
string card4 = "Wood";
string card5 = "Organic";
string card6 = "Fabric";
string card7 = "Glass";
string card8 = "Metal";
string card9 = "Water";
string card10 = "Ground";
string card11 = "Wall";
string card12 = "Floor";
string card13 = "Building";
string card14 = "Wallpaper";
string card15 = "Road";
string card16 = "Misc";

//Temporary variables for processing
string texture_card; // Name of the card to be read.
list texture_info; // The resulting data pushed into a list
integer nline; // The line count for the card reader
key nkey; // The key of thge card being read


initialize(string _action) {
//Due to the execution order when using dataserver, this function sets the first card to
//be read, and the excetuion finishes when called again with the _action set to "finish".
if (_action == "") {
loadNoteCard(texture_card);
} else if (_action = "finish") {
// All cards have been read into the lists... now you can do any kind of string
// manipulations to get the data you need to set your script.
// But here we will prove that the cards have been read with a loop
integer end = llGetListLength(text1);
// Don't be a noob scripter - evaluate end once
// for (i=0; i< LLGetListLength(gOneCard); i++)
// is just so wrong and laggy! THINK and reduce lag.
integer i;
for (i = 0; i< end; i++)
llSay(0, llList2String(text1,i));
end = llGetListLength(text2);
for (i = 0; i< end; i++)
llSay(0, llList2String(text2,i));
end = llGetListLength(text3);
for (i = 0; i< end; i++)
llSay(0, llList2String(text3,i));
end = llGetListLength(text4);
for (i = 0; i< end; i++)
llSay(0, llList2String(text4,i));
end = llGetListLength(text5);
for (i = 0; i< end; i++)
llSay(0, llList2String(text5,i));
end = llGetListLength(text6);
for (i = 0; i< end; i++)
llSay(0, llList2String(text6,i));
end = llGetListLength(text7);
for (i = 0; i< end; i++)
llSay(0, llList2String(text7,i));
end = llGetListLength(text8);
for (i = 0; i< end; i++)
llSay(0, llList2String(text8,i));
end = llGetListLength(text9);
for (i = 0; i< end; i++)
llSay(0, llList2String(text9,i));
end = llGetListLength(text10);
for (i = 0; i< end; i++)
llSay(0, llList2String(text10,i));
end = llGetListLength(text11);
for (i = 0; i< end; i++)
llSay(0, llList2String(text11,i));
end = llGetListLength(text12);
for (i = 0; i< end; i++)
llSay(0, llList2String(text12,i));
end = llGetListLength(text13);
for (i = 0; i< end; i++)
llSay(0, llList2String(text13,i));
end = llGetListLength(text14);
for (i = 0; i< end; i++)
llSay(0, llList2String(text14,i));
end = llGetListLength(text3);
for (i = 0; i< end; i++)
llSay(0, llList2String(text15,i));
end = llGetListLength(text3);
for (i = 0; i< end; i++)
llSay(0, llList2String(text15,i));
end = llGetListLength(text16);
for (i = 0; i< end; i++)
llSay(0, llList2String(text16,i));
}

}

loadNoteCard( string _notecard ) {
texture_info = []; //clear the temp lines
texture_card = _notecard;
nline =0;
nkey = llGetNotecardLine(texture_card, nline);

}

notecardFinished(string _notecard){
// Called at the end of each notcard as it is read. The temp results are stored
// and the next card is commanded to be read.
if (_notecard == card1) {
card1 = texture_card;
loadNoteCard(card2);
} else if (_notecard == card2) {
card2 = texture_card;
loadNoteCard(card3);
}else if (_notecard == card3) {
card3 = texture_card;
loadNoteCard(card4);
}else if (_notecard == card5) {
card5 = texture_card;
loadNoteCard(card6);
}else if (_notecard == card7) {
card7 = texture_card;
loadNoteCard(card8);
}else if (_notecard == card8) {
card8 = texture_card;
loadNoteCard(card9);
} else if (_notecard == card9) {
card9 = texture_card;
loadNoteCard(card10);
} else if (_notecard == card10) {
card10 = texture_card;
loadNoteCard(card11);
} else if (_notecard == card12) {
card12 = texture_card;
loadNoteCard(card13);
} else if (_notecard == card13) {
card13 = texture_card;
loadNoteCard(card14);
} else if (_notecard == card14) {
card14 = texture_card;
loadNoteCard(card15);
} else if (_notecard == card15) {
card15 = texture_card;
loadNoteCard(card16);
} else if (_notecard ==card16) {
card16 = texture_card;
initialize("finish"); // Finally pass exection to finish the initialization.
}
}

default
{
state_entry()
{
}

touch_start(integer num_det){
initialize("");
}

dataserver(key _query_id, string _data)
{
if (_query_id == nkey) {
// this is a line of our notecard
if (_data != EOF) {
// increment line count
texture_info += [_data];
//request a next line
nline++;
nkey = llGetNotecardLine(texture_card, nline);
} else {
//The notecard has been read
//notify end of read
notecardFinished(texture_card);
}
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-01-2009 09:51
CODE

list text1; // All the lines from from the first card
list text2;
list text3;
list text4;
list text5;
list text6;
list text7;
list text8;
list text9;
list text10;
list text11;
list text12;
list text13;
list text14;
list text15;
list text16;

string card1 = "Rock"; //Set these to the name of the inventory item.
string card2 = "Tile";
string card3 = "Stone";
string card4 = "Wood";
string card5 = "Organic";
string card6 = "Fabric";
string card7 = "Glass";
string card8 = "Metal";
string card9 = "Water";
string card10 = "Ground";
string card11 = "Wall";
string card12 = "Floor";
string card13 = "Building";
string card14 = "Wallpaper";
string card15 = "Road";
string card16 = "Misc";

//Temporary variables for processing
string texture_card; // Name of the card to be read.
list texture_info; // The resulting data pushed into a list
integer nline; // The line count for the card reader
key nkey; // The key of thge card being read

initialize(string _action) {
//Due to the execution order when using dataserver, this function sets the first card to
//be read, and the excetuion finishes when called again with the _action set to "finish".
if (_action == "") {
llOwnerSay("initialize if");
loadNoteCard(card1);//the first card was never being called
}
else if (_action == "finish") {//needed == not = common mistake
llOwnerSay("initialize finish");
// All cards have been read into the lists... now you can do any kind of string
// manipulations to get the data you need to set your script.
// But here we will prove that the cards have been read with a loop
integer end = llGetListLength(text1);
// Don't be a noob scripter - evaluate end once
// for (i=0; i< LLGetListLength(gOneCard); i++)
// is just so wrong and laggy! THINK and reduce lag.
integer i;
for (i = 0; i < end; i++)
llSay(0, llList2String(text1, i));
end = llGetListLength(text2);
for (i = 0; i < end; i++)
llSay(0, llList2String(text2, i));
end = llGetListLength(text3);
for (i = 0; i < end; i++)
llSay(0, llList2String(text3, i));
end = llGetListLength(text4);
for (i = 0; i < end; i++)
llSay(0, llList2String(text4, i));
end = llGetListLength(text5);
for (i = 0; i < end; i++)
llSay(0, llList2String(text5, i));
end = llGetListLength(text6);
for (i = 0; i < end; i++)
llSay(0, llList2String(text6, i));
end = llGetListLength(text7);
for (i = 0; i < end; i++)
llSay(0, llList2String(text7, i));
end = llGetListLength(text8);
for (i = 0; i < end; i++)
llSay(0, llList2String(text8, i));
end = llGetListLength(text9);
for (i = 0; i < end; i++)
llSay(0, llList2String(text9, i));
end = llGetListLength(text10);
for (i = 0; i < end; i++)
llSay(0, llList2String(text10, i));
end = llGetListLength(text11);
for (i = 0; i < end; i++)
llSay(0, llList2String(text11, i));
end = llGetListLength(text12);
for (i = 0; i < end; i++)
llSay(0, llList2String(text12, i));
end = llGetListLength(text13);
for (i = 0; i < end; i++)
llSay(0, llList2String(text13, i));
end = llGetListLength(text14);
for (i = 0; i < end; i++)
llSay(0, llList2String(text14, i));
end = llGetListLength(text3);
for (i = 0; i < end; i++)
llSay(0, llList2String(text15, i));
end = llGetListLength(text3);
for (i = 0; i < end; i++)
llSay(0, llList2String(text15, i));
end = llGetListLength(text16);
for (i = 0; i < end; i++)
llSay(0, llList2String(text16, i));
}

}

loadNoteCard(string _notecard) {
texture_info =[]; //clear the temp lines
texture_card = _notecard;
nline = 0;
llOwnerSay("loadNoteCard name = " + texture_card);
nkey = llGetNotecardLine(texture_card, nline);

}

notecardFinished(string _notecard) {
// Called at the end of each notcard as it is read. The temp results are stored
// and the next card is commanded to be read.
if (_notecard == card1) {
card1 = texture_card;
loadNoteCard(card2);
}
else if (_notecard == card2) {
card2 = texture_card;
loadNoteCard(card3);
}
else if (_notecard == card3) {
card3 = texture_card;
loadNoteCard(card4);
}
else if (_notecard == card5) {
card5 = texture_card;
loadNoteCard(card6);
}
else if (_notecard == card7) {
card7 = texture_card;
loadNoteCard(card8);
}
else if (_notecard == card8) {
card8 = texture_card;
loadNoteCard(card9);
}
else if (_notecard == card9) {
card9 = texture_card;
loadNoteCard(card10);
}
else if (_notecard == card10) {
card10 = texture_card;
loadNoteCard(card11);
}
else if (_notecard == card12) {
card12 = texture_card;
loadNoteCard(card13);
}
else if (_notecard == card13) {
card13 = texture_card;
loadNoteCard(card14);
}
else if (_notecard == card14) {
card14 = texture_card;
loadNoteCard(card15);
}
else if (_notecard == card15) {
card15 = texture_card;
loadNoteCard(card16);
}
else if (_notecard == card16) {
card16 = texture_card;
initialize("finish"); // Finally pass exection to finish the initialization.
}
}

default {
state_entry() {
}

touch_start(integer num_det) {
initialize("");
}

dataserver(key _query_id, string _data) {
if (_query_id == nkey) {
// this is a line of our notecard
if (_data != EOF) {
// increment line count
texture_info +=[_data];
//request a next line
nline++;
nkey = llGetNotecardLine(texture_card, nline);
}
else {
//The notecard has been read
//notify end of read
llOwnerSay(llList2CSV(texture_info));
llOwnerSay(texture_card = " read");
notecardFinished(texture_card);
}
}
}
}

Added some debug to see what was happening. I created two notecards; "Rock" & "Tile" and in this I wrote:
rockTest1
rockTest2
tileTest1
tileTest2

when the button was pushed this was the debug chat:
"Object: initialize if
Object: loadNoteCard name = Rock
Object: rockTest1
Object: rockTest2
Object: read
Object: rockTest1, rockTest2"

You can clearly see that the next notecard name is never assigned or called and "finish" is never called.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-01-2009 09:54
From: Sindy Tsure
(and I still say to use llGetLinkName(llDetectedLinkNumber(0)).. just you wait until you touch the link set and it all gets renumbered in some seemingly random order!)

Agreed!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
1 2