These forums are CLOSED. Please visit the new forums HERE
CSV reading & writing in prim description |
|
Fillo Farber
Registered User
Join date: 6 Jun 2004
Posts: 60
|
10-16-2009 06:54
I'm looking for the best approach to storing and reading a vector and rotation in a prim description. Would you use <>'s or just comma separated numbers? Does anyone have an example of something like this? I think writing is not so big an issue as is reading and parsing to me since I've not had experience with this. An example of both would be appreciated though. Thanks in advance!
|
Vance Adder
Registered User
Join date: 29 Jan 2009
Posts: 402
|
10-16-2009 07:11
I'd just do it as a string of comma seperated values. Seems logical to me and that is how I've seen other people do it too.
Just retrieve the object description with llGetObjectDesc: and then use llCSV2List: |
Benson Compton
Registered User
Join date: 17 Nov 2007
Posts: 14
|
10-16-2009 07:33
I used this approach in a tp script recently. The prim description contains a description to display in hover text and the location in a vector. Since the vector value contains commas I delimited the description and vector with a colon then used llParseString2List. Also, I used llStringTrim to remove any leading and/or trailing spaces from the values before doing any sort of work with them. If you take this approach, you'll have to surround vector values with < >
|
Fillo Farber
Registered User
Join date: 6 Jun 2004
Posts: 60
|
10-16-2009 17:17
This is my prim description:
<-2.60991, -1.03969, 0.44254><0.06595, -0.44130, -0.13228, 0.88510> The following line works fine: list pos_rot=llCSV2List(llGetObjectDesc()); But these two lines return invalid vectors: vector pos =llList2Vector(pos_rot,0); rotation rot =llList2Rot(pos_rot,1); I'm getting these values for pos and rot: <0.00000, 0.00000, 0.00000> <0.00000, 0.00000, 0.00000, 1.00000> What am I doing wrong here. It would seem straight forward but I've obviously missed something. Thanks again... |
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-16-2009 17:56
This is my prim description: <-2.60991, -1.03969, 0.44254><0.06595, -0.44130, -0.13228, 0.88510> The following line works fine: list pos_rot=llCSV2List(llGetObjectDesc()); But these two lines return invalid vectors: vector pos =llList2Vector(pos_rot,0); rotation rot =llList2Rot(pos_rot,1); I'm getting these values for pos and rot: <0.00000, 0.00000, 0.00000> <0.00000, 0.00000, 0.00000, 1.00000> What am I doing wrong here. It would seem straight forward but I've obviously missed something. Thanks again... Take a look at /54/37/345198/1.html, a thread earlier this week where a similar question came up. _____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....
![]() Look for my work in XStreetSL at |
Fillo Farber
Registered User
Join date: 6 Jun 2004
Posts: 60
|
10-16-2009 18:36
Thanks for the link Rolig but I don't see the relationship to my questing regarding parsing this string. Maybe you'll have to rub my nose in it lol.
What's weird is I found that: vector pos =(vector)llList2String(pos_rot,0); Returns the correct vector while: rotation rot =(rotation)llList2String(pos_rot,1); Does not return a valid rotation.... Does nothing in LSL make sense??? |
Jesse Barnett
500,000 scoville units
![]() Join date: 21 May 2006
Posts: 4,160
|
10-16-2009 18:43
CODE
returns: vector= <-2.60991, -1.03969, 0.44254> rotation = <0.06595, -0.44130, -0.13228, 0.88510> _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
Fillo Farber
Registered User
Join date: 6 Jun 2004
Posts: 60
|
10-16-2009 21:10
Thank you Jesse, I appreciate the info very much.
Would anyone like to explain what the llList2Vector and llList2Rot are used for and how? I read the wiki and thought I was on the right track with those but apparently not. While I got my answer on how to do this I am curious to learn what these other functions are used for. Thanks everyone for your time! |
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-16-2009 21:42
llList2Vector and llList2Rot will return a vector or rotation that are in a list, but only if they are stored in the list as a vector or a rotation. You can't use those functions to typecast a value that is stored as, say, a string. If you try, you will get NULL_VECTOR or NULL_ROTATION.
So llList2Vector([1, 2.3, <1,2,3>, "<4,5,6>"], 2) will yield <1,2,3> but llList2Vector([1, 2.3, <1,2,3>, "<4,5,6>"], 3) will yield <0,0,0> _____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....
![]() Look for my work in XStreetSL at |
Fillo Farber
Registered User
Join date: 6 Jun 2004
Posts: 60
|
10-16-2009 21:54
ah I see...
so they have to be CSV as well as in <>. I read the wiki to say it treated numbers between the <> as a single vector value - didn't pick up on the fact you still need the comma too. This is why I got null values. Thanks. |