Jump to content

Texture-change with Hovertext change on Click


crypticzynergy
 Share

You are about to reply to a thread that has been inactive for 3756 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm new to scripting so please bear with me... This will sound simple to probably everyone but me! LOL

I'd like to create a rectangular prim that displays a photo and a hovertext that gives some info regarding the photo on display. Upon click, the texture should change to the next one in its inventory, and the hovertext should change as well to describe the 2nd photo. Another click, another pic... Until it's back to the 1st pic & cycles thru the list.

I have figured out how to display a multi-line hovertext (the colors are still driving me bonkers), I have figured out how to display a texture on one side of a prim... But I can't figure out how to make both hovertext & texture display together, and then have both change upon click/touch.

Could someone show me how to create such a script? Thanks in advance!

Link to comment
Share on other sites

What you are trying to do will involve cycling through a pair of lists, one for the names of your photos and the other for the captioning that you want to put in hover text.  You can build those two as global lists, at the top of your script.  Then all you need to do is write your touch_start event to step through the pair of lists, one index at a time, each time someone clicks.  The easiest way to manage that is to just keep incrementing a counter (gCount) with each click.  So, start with gCount = 0 and then something like this ....

touch_start(integer num){    llSetTexture(llList2String(gMy_photos,gCount), face_no_goes_here);    llSetText(llList2String(gMyCaptions,gCount),<1.0,1.0,1.0>, 1.0);    ++gCount;   // Here's your global integer counter    if (gCount == llGetListLength(gMy_Photos) )    {        gCount = 0;    }}

 You can certainly make this more elegant, but that's the general sense of it.

 

 

Link to comment
Share on other sites

I'm not sure I understand... Here's what I have, but it keeps giving me a syntax error on line 14 (touch start).

 

default{    touch_start(integer total_number) {        llSetTexture("pic1.png",1);        llSetText("msg1", <0,0,1.0>, 1.0);        llSetTexture("pic2.png",1);        llSetText("msg2", <0,0,1.0>, 1.0);    }}touch_start(integer num){    llSetTexture(llList2String(gMy_photos,gCount), 1);    llSetText(llList2String(gMyCaptions,gCount),<1.0,1.0,1.0>, 1.0);    ++gCount;   // Here's your global integer counter    if (gCount == llGetListLength(gMy_Photos) )    {        gCount = 0;    }}

 

Link to comment
Share on other sites

Two mistakes:

1. You have an extra closed bracket ( } ) after your first touch_start event, so that's the end of state default.  Anything after that is being interpreted as another state (which you haven't opened).

2.  If you meant to have both touch_start events in the same state, that's a no-no.  You can only have one instance of any event in the same state.  In this case, you don't mean to have two touch_start events at all.

Study http://wiki.secondlife.com/wiki/Category:LSL_Events

and work though a couple of the basic tutorials at http://wiki.secondlife.com/wiki/LSL_Tutorial

Link to comment
Share on other sites

And that is why i do not put brackets at the end ends of lines. To easy to miss.

 touch_start(integer total_number) {

 you have gMy_photos in one and gMy_Photos in the other. TYPO

integer gCount;integer gFace = 1;//change for other faceslist gMy_photos = ["pic1.png","pic2.png"];list gMyCaptions = ["msg1","msg2"];default{	state_entry()	{		llSetText("", ZERO_VECTOR, 0.0);//clear the asset	}	touch_start(integer num)	{		llSetTexture(llList2String(gMy_photos,gCount), gFace);		llSetText(llList2String(gMyCaptions,gCount),<1.0,1.0,1.0>, 1.0);		++gCount;   // Here's your global integer counter		if (gCount == llGetListLength(gMy_photos) )		{			gCount = 0;		}	}}

 

 EDITED, SL color chart.

http://lslwiki.net/lslwiki/wakka.php?wakka=color

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3756 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...