Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Unusual list and llList2<x> behaviour

Leffard Lassard
Registered User
Join date: 15 Mar 2006
Posts: 142
03-30-2006 12:09
Hi together,
I am facing an unsusual behaviour of a list that should be accessed with llList2<x> functions. Unfortunately I can't provide a little test programm, because the test programm I did worked fine, but my real code does not :-(.

An example snipplet of the code is the following:
CODE

debugSay( "You are there(1).. " + llDumpList2String( params, " " ));
vector pos = llList2Vector( params, 0 );
rotation rot = llList2Rot( params, 1 );
float dist = llList2Float( params, 2 );
debugSay( "Where are you? " + (string) pos + " " + (string)rot + " " + (string) dist );
debugSay( "You are there(2).. " + llDumpList2String( params, " " ));

And the output for this is:
CODE

*debug*You are there(1).. <71.097794, 242.469391, 49.105293> <0.000000, 0.000000, 0.992262, 0.124164> 73
*debug*Where are you? <0.00000, 0.00000, 0.00000> <0.00000, 0.00000, 0.00000, 1.00000> 73.000000
*debug*You are there(2).. <71.097794, 242.469391, 49.105293> <0.000000, 0.000000, 0.992262, 0.124164> 73


As I see it, the values consisting out of one vector, a rotation and a float are in the list and are accessed by llDumpList2String, but can't be accessed by llList2Vector and llList2Rot, though llList2Float works fine.
Has someone else seen such an unusual behaviour before and knows what to look for, what could be wrong in my code (probably somewhere else)?
I hope, someone knows what to look for, because I haven't seen something weird before and don't know what to do.
So, to precise the issue, what reasons are there, that llList2<x> functions fail silently?

Regards,
Leff.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
03-30-2006 12:21
From the Wiki:

From: someone

Q: Have the old problems concerning the odd behavior of llList2Vector and llList2Rot when requesting a TYPE_STRING element from the list been fixed yet?

A: No. If a list element is a string containing text that would otherwise be directly typecast to a vector or rotation, It will not be converted. The resulting vector or rotation will be ZERO_VECTOR or ZERO_ROTATION respectively. This is a bug. To get around it, use llList2String to retrieve elements from your list, then cast them to vectors or rotations as needed: (vector)llList2String(positions,2);


I think there are differences with whether the list was created as:

CODE
params += [<x,y,z>];


vs:

CODE
params += ["<x,y,z>"];


Either way, I don't bother, I always use llList2String and typecast it to vector/rotation/float/whatever. Sure, it's slower, but it works, and I don't have to worry about how my list was created.
Leffard Lassard
Registered User
Join date: 15 Mar 2006
Posts: 142
Solved by myself.
03-30-2006 12:28
Thanks, I found that few minutes afterwards... Sometimes lsl is such a pain :-( (or is it always?).
I forgot, the list is built up after a link_message event, and the values in the list, at least the vector and the rotation, are strings, not the real values. So the conversion that works is the following:

CODE

debugSay( "You are there(1).. " + llDumpList2String( params, " " ));
vector pos = (vector)llList2String( params, 0 );
rotation rot = (rotation)llList2String( params, 1 );
float dist = llList2Float( params, 2 );
debugSay( "Where are you? " + (string) pos + " " + (string)rot + " " + (string) dist );
debugSay( "You are there(2).. " + llDumpList2String( params, " " ));


Regards,
Leff.