Jump to content

question about saving a list


Vette Jewell
 Share

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

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

Recommended Posts

So I;m sure there is an obvious way to do this, but it's just not clicking for me.

 

I want to have a script that asks several questions and the answeres are typed into a dialog box.  I have that part working,

 

But how do I save the answeres into a single list that an can use later?

 

 

Also on a seperate note, any suggestions and why I can't save scripts?  I cleared my ache and that didn't help.  I also tried an alt and used different regions.  

 

Thanks soooo much for any help!

Link to comment
Share on other sites

Here are the important events ...

touch_start(integer num){
llListenRemove(giLsn); giLsn = llListen(-12345,"","",""); llDialog(llDetectedKey(0)," \n Pick an answer ... any answer ...",["A","B","C","D"],-12345); gsName = llDetectedName(0); llSetTimerEvent(10.0);}listen (integer channel, string name, key id, string message){ llListenRemove(giLsn); glAllAnswers += [gsName,message];}timer(){ llListenRemove(giLsn); llSetTimerEvent(0.0);}

The global list glAllAnswers stores the name and response that each toucher gives, as a strided (2) list.

Link to comment
Share on other sites

EDITED

 

You should first look up what global variables are. In LSL a local variable stores information temporally (for the duration of the event) while a global variable stores information permanently. If you are using a local variable, then each time the event happens (in this example with each listening event) the variable is called from scratch and has ONLY the value that you give it at this moment. It loses all information it was containing before. A global variable does start the computation process with the results that it already includes.

 

You need to define them (including the list) before the state default.

 

In case that this is also unclear: Then you should look up in the lsl wiki on how to add elements to a list. There are several ways to do so.

 

Good luck!

Link to comment
Share on other sites

Thanks agin!

 

So now anouther question about the list.  I think I know where it's going wrong..

Everytime it adds a new answere to the list I have it it also add a comma to seperate them, but then of course it adds a comma on to the end of the last answere. so when I try to read those answeres I get 0 instead of the answere.  I think thats why anyways?

I can see how to remove all the commas, but can't figure out how to only remove the last one.

        message = llStringTrim(message, STRING_TRIM);    glAllAnswers += [message+","];         llSay(0,(string)glAllAnswers);         Next();
list    glAllAnswers  = llGetLinkPrimitiveParams(2,[PRIM_DESC]);        integer One = llList2Integer(glAllAnswers, 0);        integer Two = llList2Integer(glAllAnswers, 1);        integer Three = llList2Integer(glAllAnswers, 2);        llSay(0,"Apples"+" "+(string)One+" "+(string)Two+"!" +" "+(string) Three);

So the returns Apples 0 0! 0 with 0 for the answeres.

Link to comment
Share on other sites

When you add elements to a list like that, you don't need to add extra commas.  There aren't actually any commas in the list anyway.  Just write

glAllAnswers += [message];

Try this:

list glAllAnswers;default{    touch_start(integer num)    {        integer i;        while (i < 10)        {            gAllAnswers += [(string) i];            llSay(0,"glAnswers = " + llList2CSV(glAllAnswers) );            ++i;        }    }}

The only reason that you see commas in the output is that llList2CSV puts them there as a convenience.

 

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...