Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple Question.....

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-16-2009 19:39
I hope, lol

I am trying to bring a vector in from a nc, but it doesnt seem to work. Am I doing this correct or am I missing something? This is how I am doing it.

vector norm;

string norm1 = llList2String(notecardList,(index*5)+1);
norm1 = (string)norm;


Thanks for any in site I can get.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
07-16-2009 20:23
I think you want to say,
CODE
 vector norm1 = (vector) llList2String(notecardList,(index*5)+1);
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-16-2009 21:41
Thank you!
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
07-17-2009 02:09
or

vector norm1 = llList2Vector(notecardList,(index*5)+1);
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-17-2009 02:20
From: Beverly Ultsch
or

vector norm1 = llList2Vector(notecardList,(index*5)+1);

No. That will *not* work. llList2Vector picks a vector out of a list.
It *does not* cast if it is not already a vector, so if your list is a list of strings, you'd get a zero-vector; the default for an invalid operation.
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
07-17-2009 02:28
Opps, I stand corrected :)
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
07-17-2009 05:36
This bit me once, which is why I remembered it.. I spent ages trying to figure out why something that worked perfectly when I read the list of vectors from the script fell over when I copied the list over to a notecard and tried to read it from there. It's the same with rotations, as I recall.
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-17-2009 05:44
Yes, it's a fairly obscure quirk in LSL, based on the fact that list items are strongly typed.

llList2String automatically casts (since anything can be cast to string), so you can always pick something out of a list using that, but none of the other llList2... methods do; they attempt to pick out the specific type, and will return an appropriate null-value (ZERO_VECTOR, ZERO_ROTATION) if the item is not of the expected type.

ETA: llList2Key also casts, based on the fact that keys for all practical purposes are treated as strings, nevermind whether what's in them is on the format of a key, let alone a valid key.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-17-2009 07:49
you pretty much have two choices, cast it to a vector when you get it from a notecard (preferable) or cast it to a vector when you use it... stupid, but true.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-17-2009 10:12
All of the llList2*() functions cast EXCEPT for llList2Vector() and llList2Rot(). I'd actually prefer that NONE of them did except for llList2String(), but there you go.