diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index 3cf880c..d26a31e 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c | |||
@@ -257,6 +257,62 @@ static void evaluateNoToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) | |||
257 | 257 | ||
258 | static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) | 258 | static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) |
259 | { | 259 | { |
260 | /* Typecasting | ||
261 | |||
262 | LSL is statically typed, so stored values are not converted, only the values used in expressions are. | ||
263 | Lua is dynamically typed, so stored values are changed (sometimes I think). | ||
264 | |||
265 | LSL implicitly typecasts - There is a shitload of QUIRKs about this. Apparently some don't work anyway. | ||
266 | integer -> float (Says in lslwiki that precision is never lost, which is bullshit, since they are both 32 bit. Would be true if the float is 64 bit. Lua suggest to use 64 bit floats to emulate 32 bit integers.) | ||
267 | string -> key | ||
268 | Some functions need help with this or the other way around. | ||
269 | string -> vector (Maybe, should test that.) | ||
270 | vector -> string (Maybe, should test that.) | ||
271 | Also happens when getting stuff from lists. | ||
272 | |||
273 | Explicit type casting - | ||
274 | string -> integer | ||
275 | Leading spaces are ignored, as are any characters after the run of digits. | ||
276 | All other strings convert to 0. | ||
277 | Which means "" and " " convert to 0. | ||
278 | Strings in hexadecimal format will work. | ||
279 | keys <-> string | ||
280 | No other typecasting can be done with keys. | ||
281 | float -> string | ||
282 | You get a bunch of trailing 0s. | ||
283 | |||
284 | QUIRK - I have seen cases where a double explicit typecast was needed in SL, but was considered to be invalid syntax in OS. | ||
285 | |||
286 | Any binary operation involving a float and an integer implicitly casts the integer to float. | ||
287 | |||
288 | A boolean operation deals with TRUE (1) and FALSE (0). Any non zero value is a TRUE (generally sigh). | ||
289 | Bitwise operations only apply to integers. The shifts are arithmatic, not logical. Right shifted bits are dropped, left shifts the sign bit. | ||
290 | |||
291 | intefer = integer0 % integer1; // Apparently only applies to integers. | ||
292 | string = string0 + string1; // Concatenation. | ||
293 | list = list0 + list1; // Concatenation. Also works if either is not a list, it's promoted to a list first. | ||
294 | list = (list=[]) + list + ["new_item"]; // Voodoo needed for old LSL, works in Mono but not needed, does not work in OS. Works for strings to. | ||
295 | list == != // Only compares the lengths, probably applies to the other conditionals to. | ||
296 | vector = vector0 + vector1; // Add elements together. | ||
297 | vector = vector0 - vector1; // Subtract elements of vector1 from elements of vector0. | ||
298 | float = vector0 * vector1; // A dot product of the vectors. | ||
299 | vector = vector0 % vector1; // A cross product of the vectors. | ||
300 | vector = vector * float; // Scale the vector, works the other way around I think. | ||
301 | vector = vector * integer; // Scale the vector, works the other way around I think. | ||
302 | vector = vector / float; // Scale the vector, works the other way around I think. | ||
303 | vector = vector / integer; // Scale the vector, works the other way around I think. | ||
304 | vector = vector * rotation; // Rotate the vector by the rotation. Other way around wont compile. | ||
305 | vector = vector / rotation; // Rotate the vector by the rotation, in the opposite direction. Other way around wont compile. | ||
306 | rotation = llGetRot() * rotation; // Rotate an object around the global axis. | ||
307 | rotation = rotation * llGetLocalRot(); // Rotate an object around the local axis. | ||
308 | rotation = rotation0 * rotation1; // Add two rotations, so the result is as if you applied each rotation one after the other. | ||
309 | rotation = rotation0 + rotation1; // Similar to vector, but it's a meaningless thing as far as rotations go. | ||
310 | rotation = rotation0 - rotation1; // Similar to vector, but it's a meaningless thing as far as rotations go. | ||
311 | // Division rotates in the opposite direction. | ||
312 | |||
313 | */ | ||
314 | |||
315 | |||
260 | if (content) | 316 | if (content) |
261 | { | 317 | { |
262 | #ifdef LUASL_DEBUG | 318 | #ifdef LUASL_DEBUG |