Jump to content

counter for names


testgenord1
 Share

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

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

Recommended Posts

Hi again!
I have made a quiz.
After solving the quiz, the players' names are supposed to be displayed in a floating text above the quiz prim.
I can already display the name of one successful player (see script excerpt below).

What I would like to do, though, is to display the names of more than one succesful player (let's say the last 5 succesful players' names).
There is certainly a way to do this, but I just cannot figure it out.

Any help will be appreciated.
Thank you very much in advance.

the script excerpt mentioned above:

llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users) 
}   
listen(integer channel, string name, key id, string message)
{
   if (message == correct_answer)
   {
            llSetText(name+" has solved the quiz!",<1.0, 1.0, 1.0>,1.0);    
    }

 

Link to comment
Share on other sites

Thank you very much!
Here's what I ended up with:
 

integer length;
list visitors =[];

default
{
    state_entry()
    {
llListen(0, "", NULL_KEY, ""); // listen for dialog answers (from multiple users) 
}   
listen(integer channel, string name, key id, string message)
{
   if (message == "correct answer")
   {
visitors=visitors+name;
length = llGetListLength(visitors);
integer i;
for (i=0;i<length;++i)
llSetText(llDumpList2String(visitors,","), <0,1,0>, 1);
	}
	}
}

There are two things I couldn't figure out:
- The list above somehow double-records itself before you get the output,
which means you do not only get the updated list, but the old list in addition.

- llList2String didn't seem to work.
Is it necessary to use llDumpList2String?
Why can you not just use llList2String?

Do you have an idea why this is the case?
Thank you.

Link to comment
Share on other sites

I'm not sure that I understand why you have built a loop around the llSetText statement.  You only need to display it once.  You accomplish that, as you have, by simply writing

visitors += [name];

And you use llDumpList2String here because you want the entire list to show in your hover text, not just a single element from the list, as would be the case if you used llList2String. What I would change, however, is to make the llDumpList2String part look like

llDumpList2String(visitors, "\n")

That will put each of the names in your list onto a separate line in hover text.  Splitting the list elements with commas, as you have, is the same as using 

llList2CSV(visitors)

which puts them all on a single long line. 

The reason that I pointed you to the scrolling text script, of course, is that there is a practical limit to how much text you can jam into a hover text message.  You'll hit that limit when you have a dozen or so students.  At that point, it makes sense to regenerate the hover text a line at a time and let the script scroll through the whole list with a timer.  That's what that script does.

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1648 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...