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
11-01-2009 10:36
ok, i got the notecard reader working. awesome and ty. now im trying to add the buttons so they load up the specific notecard.
im taking your advice and useeinf "llGetLinkedName(llDetectedLinkNumber(0));" works great. thanks for that advice.
NOW here is my problem. i put the buttons uner the "touch_start" section of the script.
so it looks something like this....
CODE

touch_start(integer num_det)
{
string button = llGetLinkName(llDetectedLinkNumber(0));

if (button == "Rock")
{
nkey = llGetNotecardLine("Rock", nline);
llOwnerSay("Rock notecard loaded");
initialize("");
}
else if (button == "Tile")
{
llGetNotecardLine("Tile", nline);
llOwnerSay("Tile notecard loaded");
initialize("");
}
}


now i know one of then just had the GetNotecardLine and the other one says nkey = blah blah blah. i did that trying diffrent methods. either way i work it it loads up the same notecard. dont think its supposed to work like that. so the way i have it written, especially with the Tile button, it should load up that notecard and display the information in it. yes i have the notecard in there with something written in it. so im thinking its something in the dataserver part maybe.

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)
{
string button = llGetLinkName(llDetectedLinkNumber(0));

if (button == "Rock")
{
nkey = llGetNotecardLine("Rock", nline);
llOwnerSay("Rock notecard loaded");
initialize("");
}
else if (button == "Tile")
{
nkey = llGetNotecardLine("Tile", nline);
llOwnerSay("Tile notecard loaded");
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);
}
}
}
}


there is what it looks like now.
Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
11-02-2009 09:54
ok.. im sure yoiu will be glad to know that i got the buttons to work. YAY!!! now im having issues setting the textures to certain prims. now im trying to use llsetlinkedtextures but i keep getting an error. i dont see anything wrong with the section but what the hell do i konw right?? lol

CODE

string display = "(a5e62d17-8f1e-8e69-a690-0e5ddbd2b926)";

list panel = [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38];
integer views = 19;
//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

default {
state_entry() {
}
on_rez(integer start_param)
{
llSetLinkTexture("single_view0" + "single_view1" + "single_view2" + "single_view3" + "single_view4" + "single_view5" + "single_view6" + "single_view7" + "single_view8" + "single_view9" + "single_view10" + "single_view11" + "single_view12" + "single_view13" + "single_view14" + "single_view15" + "single_view16" + "single_view17" + "single_view18" + "single_view19", "a5e62d17-8f1e-8e69-a690-0e5ddbd2b926", ALL_SIDES);
llResetScript();
return;
}

touch_start(integer num_det) {
texture_card = llGetLinkName(llDetectedLinkNumber(0));
texture_info = [];
nline = 0;
nkey = llGetNotecardLine(texture_card, nline++);
llOwnerSay(texture_card + " notecard loaded");
}

dataserver(key _query_id, string _data) {
if (_query_id != nkey)
return;

// this is a line of our notecard
if (_data != EOF) {
texture_info += [_data];
nkey = llGetNotecardLine(texture_card, nline++);
} else {
llOwnerSay(llList2CSV(texture_info));
llOwnerSay(texture_card + " read");
}
}
}

Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-02-2009 10:30
You can't set several link textures at once the way you're doing it. You have to do it iteratively, like so ....

CODE

list linkNums = [2,3,4,5,6,7,8,9,10];

llSetLinkTexture(list linkNums, string texture, integer face) {
integer i;
for (i = 0; i < llGetListLength(linkNums); i++){
llSetLinkTexture(llList2Integer(linkNums, i), texture, face);
}
}
_____________________
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
11-02-2009 11:02
isnt there a way to set the linked textures of the prims to the name of the prim?
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-02-2009 12:02
Not directly. llSetLinkTexture expects a number as its first argument, not a string, so you have to feed it the link number. llGetLinkNumber() gives you the number of the link that the script is in, so that's no help. You'll have to write a little function to grab that information and build a list, something like this .....

CODE

list linkNumbers ()
{
list linkNames = ["single_view0" , "single_view1" , "single_view2" , "single_view3" , "single_view4" , "single_view5" , "single_view6" , "single_view7" , "single_view8" , "single_view9" , "single_view10" , "single_view11" ,"single_view12" , "single_view13" , "single_view14" , "single_view15" , "single_view16" , "single_view17" , "single_view18" , "single_view19"];
list links = [];
integer prims = llGetNumberOfPrims();
integer i;
for (i=0; i <= prims-2;++i)
{
string name = llGetLinkName(i+2);
links += llListFindList(linkNames,[name]) + 2;
}
}


That will give you a list (links) of link numbers in the same order as the names in the list named linkNames. So, if you want to address the link named "single_view17," you look in this new list at position 18. That's where the link number should be.

ETA: Ah..... As I look at it after a fresh cup of coffee, I see that my function is a fine generic solution, but what you actually need for your specific case is much simpler. You are trying to paint the same texture on all child prims in the linkset on rez, so you don't really care what their individual numbers are. You can just write .....

llSetLinkTexture(LINK_ALL_OTHERS,"a5e62d17-8f1e-8e69-a690-0e5ddbd2b926", ALL_SIDES);

Sorry about that. :o If you DO need to texture specific prims in the linkset rather than all of them, however, my function will give you an ordered list of link numbers to work from.

/me goes back to her corner .....
_____________________
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
11-02-2009 17:08
well actually i dont want all the child prims to be textured, just my view panels. so i think your first example would work.
1 2