From: someone
Originally posted by Tcoz Bach
I'd think -1+2*(a>0) would generate an integer, which is not a valid argument for a vector (float to int is implicit). That's why casting to float in your second example works. Your code would actually seem to show that everything is honky dory.
From: someone
From the LSL documentation3.3.1.1. Implicit Casting
LSL only supports two implicit type casts: integer to float and string to key. Thus, any place you see a float specified you can supply an integer, and any place you see a key specified, you can supply a string.
Float -> int is explicit, your effectively loosing precision.
Int -> Float on the other hand, gains precision (well, if you disreguard floating point error for a few moments), so it was made implicit.
Implicit int -> float conversion lets us do:
float f = 1;
Without getting a syntax error. 1 is actually an integer.
If we didn't have implicit int -> float conversion, we'd have to explicitly put the decimal point in every float declaration.
ex:
float f = 1.0;
Implicit means that the developer has no need to cast one type to another. It is obvious why int -> float implicit was implemented, 1 can be an integer or a float, you dont want to have to type two more keys to add the ".0".
In LSL, its often best to seperate operators, sometimes the compiler gets confused and mistakes them for variable names.
Hope this helps.
EDIT:
Ooh, wait, this actually generates a runtime math error? How absurd.
Vector math is really messed up, its best if you just perform the operation outside the vector, then when your all finished, place everying, already evaluated, into the three vector positions.