Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help - Picture viewer that dispenses notecard for each pictures.

Wen Jiutai
Registered User
Join date: 20 Sep 2006
Posts: 4
10-02-2006 19:34
Hello,

I want to make a sort of a portfolio with just a one prim cube and previous and next buttons that will show different pictures of people. I want each picture to dispense its own notecard (biography) when touched.

Please help me and point me in the right directions. :)

Thanks much!
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
10-03-2006 01:40
Find one of the free vendor scripts. Set all the biographies for sale free...

Alternatively, you need a list of pictures and notecards, back and next move you through the lists, and the touch_start event for "give biography" does llGiveInventory to llDetectedKey(0) and the notecard name.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
10-03-2006 03:39
Here's a simplified vendor script without the unneeded payment functions:

CODE
integer display;
list pics;
list items;
key k;
list temp;
integer line;
integer start=0;
integer front = 10; // Set this to the face of the prim you want the image on (0-5)
// or set it to 10 to display the image on all sides of the prim.
default
{
state_entry()
{
llListen(0,"",llGetOwner(),"reset");
if (start > 0) llMessageLinked(LINK_SET,1,"NEXT",llDetectedKey(0));
}
on_rez(integer param)
{
llResetScript();
}
listen(integer chan, string name, key id, string mes)
{
if (mes == "reset") state readCard;
}
link_message(integer link, integer num, string mes, key id)
{
if (mes == "NEXT")
{
display += 1;
if (display >= llGetListLength(items)) display = 0;
if (front != 10) llSetTexture(llList2String(pics,display - 1),front);
else llSetTexture(llList2String(pics,display - 1),ALL_SIDES);
}
else if (mes == "PREV")
{
display -= 1;
if (display < 0) display = llGetListLength(items) - 1;
if (front != 10) llSetTexture(llList2String(pics,display - 1),front);
else llSetTexture(llList2String(pics,display - 1),ALL_SIDES);
}
}
touch_start(integer nevermind)
{
llGiveInventory(llDetectedKey(0),llList2String( items,display - 1));
}
changed(integer change)
{
if (change & CHANGED_INVENTORY) state readCard;
}
}

state readCard
{
state_entry()
{
line = 0;
k = llGetNotecardLine("Config",line++);
items = [];
pics = [];
}
dataserver(key q, string data)
{
if (q == k)
{
temp = llCSV2List(data);
if (llParseString2List(data,[" "],[""]) == []);
else if (data == EOF)
{
display = 0;
llMessageLinked(LINK_SET,1,"PIC",llGetInventoryKey(llList2String(pics,0)));
llWhisper(0," * Setup complete : " + (string)llGetFreeMemory() + " bytes free.");
start=1;
state default;
}
else if (llGetListLength(temp) != 2)
{
llWhisper(0,"Error, improperly formatted line #" + (string)(line - 1));
state default;
}
else
{
items += llList2String(temp,0);
pics += llList2String(temp,1);
if ( llGetInventoryKey((key)llList2String(temp,0)) == NULL_KEY
|| llGetInventoryKey((key)llList2String(temp,1)) == NULL_KEY)
{
llWhisper(0,"Error, missing notecard or picture from line : " + data);
state default;
}
k = llGetNotecardLine("Config",line++);
}
}
}
}


Place it in the main prim, together with the notecards and an additional notecard named "Config". Enter notecard names and images in the Config notecard separated by a comma, like:
Name of 1st notecard,image name
Name of 2nd notecard,image name
and so on. Finally, have the forward / next button prims send the linkset messages "PREV" and "NEXT":
CODE
default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET,1,"PREV",llDetectedKey(0));
}
}


That's all you need :)

/Edit: don't forget to say "reset" after saving the Config notecard.
Wen Jiutai
Registered User
Join date: 20 Sep 2006
Posts: 4
10-03-2006 07:18
Hey, thanks a million zillion Ishtara!

The main script works but I can't get the PREV or NEXT button to work, when I click on it, it doesn't go to the next item... help?

Thanks again.
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
10-03-2006 08:24
Are the three prims linked? With the main display prim as root prim and the two buttons as child prims? The buttons both need the second script, one sending the linkset message PREV, the other one NEXT (in capitals).
Also, after adding the Config notecard you need to start the script by saying "reset".
Wen Jiutai
Registered User
Join date: 20 Sep 2006
Posts: 4
10-03-2006 08:36
Ishtara,

I didn't link the three buttons so that is probably why it is not working...

How do I link those three buttons?

Thanks so much for the help, I really really appreciate it!
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
10-03-2006 15:33
Wen---

To link the three objects:

1) Place all three on the ground (position them how you like)

2) Right-click on one of Button objects and select Edit

3) Now, holding the Shift key down, click the remaining two objects in this order:

- second Button object
- main Display object

4) Release the Shift key

5) Choose the Tools menu option and select Link

That should do it.

All three will be linked with the main Display object as the Root Prim.
Wen Jiutai
Registered User
Join date: 20 Sep 2006
Posts: 4
It works!
10-03-2006 18:21
Thank you all for the help... the linking got it working! Also for the Config file, there has to be a space between the comma and the name of the pic of else it is not going to work.

Thanks again!

-Wen