Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problems with casting strings to float/integer

Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
07-20-2006 15:48
So...I'm trying to program a script that will read a notecard for customizable color options for the different parts of the ship.

I've figured out that I need to read the notecard line, and parse the strings to lists...

However it is not letting me cast the strings from the list into numbers.

I've tested and llList2String(data1list, 2) will return the test value in the notecard, but I can't seem to get this value transferred to a number. I've tried doing the following: (not going to confuse the question with the rest of the script as it is only set to do testing and would just look jumbled)

CODE
 R1String = llList2String(data1list, 2); //I know this returns the correct value
R1 = (float)R1String;


But this returns with 0.00 when I do an llOwnerSay((string)R1);

Any ideas? Or does parsing and pulling the field from the list mess this up somehow?
Ralek Queso
Registered User
Join date: 3 Feb 2005
Posts: 32
07-20-2006 15:55
I use this system on MULTIPLE notecard configuration systems and it does work.

My guess? you have an extra space in that string somewhere (possibly on the notecard). Any string which contains ANYTHING other that what's accepted in a float (like a space or a comma instead of a period) will cast to zero.
_____________________
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
07-20-2006 17:01
I'm an idiot...I always get this happening..when I finally go to ask the question because I can't figure it out....


When I had found that I needed to change how I was pulling the list and created the new variables...I forgot to change the variable name in the if statement that it was called under....

/bonk