Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

getting "Back" and "Next" buttons working

Zaine Swords
Registered User
Join date: 26 Nov 2008
Posts: 47
11-07-2009 12:43
hey everyone.... again..... im trying to get a BACK abd a NEXT button working. but they are working with notecards.

i know i have to use link_message() but getting it to read the lines on the notecard seem to be hard for me and also making usre it reads from the right notecard.

here is what the Button scripts looks like..

CODE

default {
state_entry() {
}

touch_start(integer total_number) {
llMessageLinked(LINK_ROOT, 0, "next", NULL_KEY);
llSleep(0.3);
}
}


and here is what i have for the main script.

CODE

string display = "(a5e62d17-8f1e-8e69-a690-0e5ddbd2b926)";
string currentblock;
integer notenter;
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

setLinkTexture(list panel, string display, integer face)
{
integer s;
for (s = 0; s < llGetListLength(panel); s++)
{
llSetLinkTexture(llList2Integer(panel, s), display, ALL_SIDES);
}
}

default {
state_entry() {
}
on_rez(integer start_param)
{
llResetScript();
return;
}
link_message(integer sender_number, integer number, string message, key id)
{
if(message != "next" && currentblock < notenter / views)
{
currentblock++;
texture_card();
return;
}
if(message != "back" && currentblock > 0)
{
currentblock--;
texture_card();
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-07-2009 13:16
I can't see where you assign a value to the variable named "notenter," so I don't have a clue how big an integer it is. Nevertheless, take a look at your test ....

if(message != "next" && currentblock < notenter / views)

views = 19, so chances are that notenter/views is not going to come out to an integral value and will be rounded down to the next lowest integer. My guess is that it's going to be zero. If so, currentblock < notenter is likely to be FALSE, so the test will usually fail.

Unless I've missed something. ;)
_____________________
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-07-2009 16:59
the notenter is determined by how many lines there are in the notecard. and since that changes with each time you add a new line then i dont see where i can add an integer to it
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-07-2009 18:24
I don't see it ANYWHERE except where it's defined as a global integer, so its value is always zero. It's not incremented by anything I can see. Therefore notenter/views is always equal to zero. Unless I'm totally missing something.......
_____________________
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-07-2009 18:34
i think its me who is missing something... how would i go about all of this then
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-07-2009 21:26
Hard to say, Zaine. Try studying this script. It's a much simpler version of what you're trying to do, but it does sort of the same thing... gives something from the object's contents when a user clicks a dialog button. Take a look at how the two-tiered dialog with " >> " and "<< " buttons is implimented. It ought to suggest some ideas for you....

CODE

// On touch, offers user a dialog list of the object's contents and then gives user the item chosen from dialog
// As written, this script is configured to offer only notecards. To offer ANY item in inventory, change INVENTORY_NOTECARD
// everywhere in this script to INVENTORY_ALL.
// NOTE: Dialog buttons may display only about 8 characters. Some item names may be truncated in labels.

list MENU1 = [];
list MENU2 = [];
integer listener;
integer MENU_CHANNEL = 1000;
key user;

Dialog(key id, list menu)
{
llListenRemove(listener); //Ignores input from any orphaned dialog boxes
listener = llListen(MENU_CHANNEL, "", NULL_KEY, "");
llDialog(id, "Choose one object below: ", menu, MENU_CHANNEL);
}

default
{
on_rez(integer num)
{
llResetScript();
}

touch_start(integer total_number)
{
integer i = 0;
MENU1 = [];
MENU2 = [];
integer c = llGetInventoryNumber(INVENTORY_NOTECARD);
if (c <= 12)
{
for (; i < c; ++i){
MENU1 += llGetInventoryName(INVENTORY_NOTECARD, i);
}
// Next line arranges buttons in alphabetical order, top to bottom
for (i=0;i< llGetListLength(MENU1);i+=3) { MENU1 = llListInsertList(llDeleteSubList(MENU1, -3, -1), llList2List(MENU1, -3, -1), i); }
}
else
{
for (; i < 11; ++i){
MENU1 += llGetInventoryName(INVENTORY_NOTECARD, i);
}
if(c > 22)
c = 22;
for (; i < c; ++i)
MENU2 += llGetInventoryName(INVENTORY_NOTECARD, i);
MENU1 += " >> ";
// Next line arranges buttons in alphabetical order, top to bottom
for (i=0;i< llGetListLength(MENU1);i+=3) { MENU1 = llListInsertList(llDeleteSubList(MENU1, -3, -1), llList2List(MENU1, -3, -1), i); }
MENU2 += " << ";
// Next line arranges buttons in alphabetical order, top to bottom
for (i=0;i< llGetListLength(MENU2);i+=3) { MENU2 = llListInsertList(llDeleteSubList(MENU2, -3, -1), llList2List(MENU2, -3, -1), i); }
}
user = llDetectedKey(0);
Dialog(user, MENU1);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MENU_CHANNEL)
{
llListenRemove(listener);
if (message == " >> ")
{
Dialog(id, MENU2);
}
else if (message == " << ")
{
Dialog(id, MENU1);
}
else
{
llGiveInventory(user, message);
}
}
}

changed (integer change) // If an item is added to or removed from the object's inventory
{
if (change && CHANGED_INVENTORY)
{
llResetScript();
}
}
}
_____________________
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-07-2009 22:52
what im looking for is when it rezzes out some of the prims that are linked to to root prim, load up a texture as a default till another button is pressed.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-08-2009 07:13
I think we're talking past each other. I thought you wanted help making the "next" and "back" options work on your buttons. That's why I pointed out that you never gave your variable "notenter" a value anywhere. If you don't tell your script what "notenter" is, the if test I highlighted will always fail. You remarked that "the notenter is determined by how many lines there are in the notecard..... that changes with each time you add a new line ....," but that's simply not true. There's nothing in the dataserver event or anywhere else that changes notenter. It isn't even mentioned.

Now ..... all of that aside ..... your last post makes it sound as if you don't care about the "next" and "back" buttons at all, so I've been chasing a red herring. What you REALLY seem to care about now is loading a default texture. I'm confused, and I need my morning coffee.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-08-2009 08:44
From: Rolig Loon
I'm confused, and I need my morning coffee.

Coffee smells like freshly ground heaven. ~Jessi Lane Adams

Zaine, big picture time now. Exactly what is the end product you are shooting for? I half understand the different parts you are trying to get working. But if we understand the end product you are trying for then we might be able to save you some time and frustration by better focusing our answers.
_____________________
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
11-08-2009 12:04
ok taht last post of mine was my mistake.. i was tryinjg to do 2 things at once and got confused as to where i was. So Rolig you being comfused is understandable and was my fault. aorry about that. but what im trying for is a texture changer that reads from a notecard. the script reads the UUID keys and the name off the notecards and displays what the texture looks like on small panels. clicking on one of the smaller panels will bring up a larger view of the texture you clicked on. course since you might have multipul pages i would need the next and back button to work to scan through the other textures. i hope this somewhat clarifies a little bit.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-08-2009 12:13
OK, so what's your question, then? Is something not working... other than the if test that I have pointed out many times 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
11-08-2009 12:24
that gives you the object. i need the next and back button to scan though, need it to work off a notecard, and i dont want it menu driven
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-08-2009 12:52
OK. Let's start with your link_message event, then. I've embedded a few observations in the code I grabbed from your first post ....

CODE

link_message(integer sender_number, integer number, string message, key id)
{
if(message != "next" && currentblock < notenter / views)
// The variable "notenter" always has the value ZERO, so this block of code will never execute. This needs fixing.
{
currentblock++;
texture_card();
//The function called "texture_card()" does not exist. You will get a compile error here unless you provide the function. Also, it is bad form (and confusing) to give
a variable and a function the same name. Choose another name.

return;
//Why is this "return" here? See my next comment.
}
if(message != "back" && currentblock > 0)
//This block shouldn't be executed if the previous one was successful, right? The test here should be "else if", not "if".
{
currentblock--;
texture_card();
//Same here
return;
// There's no need for a "return" here. The event is terminating anyway.
}
}


Aside from the syntactic questions, let me ask a logical one. Why are you testing to see if the message from your linked prim is not "next" or "back"? If I understand what you're trying to do, it looks as if you want to move to the next texture is the message is "next", and the reverse if it's "back." The way to approach logical questions like this is to draw yourself a diagram, like a wiring diagram that an electrician might draw. Map out all the pathways you need to consider and then ask yourself how well your script conforms to the map. You're lots closer to the project than I am, so that's your job.
_____________________
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-08-2009 13:54
ok yea.. i think i need my morning coffee cause what you just said went right over my head.. lol