Vette Jewell Posted April 9, 2016 Posted April 9, 2016 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!
Vette Jewell Posted April 9, 2016 Author Posted April 9, 2016 I have it set with a listen for the replies also, and its recieving the answeres, just not sure what to do with them to get them into a list as I recieve them.
Rolig Loon Posted April 9, 2016 Posted April 9, 2016 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.
Estelle Pienaar Posted April 9, 2016 Posted April 9, 2016 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!
Vette Jewell Posted April 10, 2016 Author Posted April 10, 2016 Thank you both! That helps sooooo much!
Vette Jewell Posted April 14, 2016 Author Posted April 14, 2016 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.
Rolig Loon Posted April 14, 2016 Posted April 14, 2016 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.
Recommended Posts
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