aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.c56
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
258static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) 258static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right)
259{ 259{
260/* Typecasting
261
262LSL is statically typed, so stored values are not converted, only the values used in expressions are.
263Lua is dynamically typed, so stored values are changed (sometimes I think).
264
265LSL 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
273Explicit 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
284QUIRK - I have seen cases where a double explicit typecast was needed in SL, but was considered to be invalid syntax in OS.
285
286Any binary operation involving a float and an integer implicitly casts the integer to float.
287
288A boolean operation deals with TRUE (1) and FALSE (0). Any non zero value is a TRUE (generally sigh).
289Bitwise operations only apply to integers. The shifts are arithmatic, not logical. Right shifted bits are dropped, left shifts the sign bit.
290
291intefer = integer0 % integer1; // Apparently only applies to integers.
292string = string0 + string1; // Concatenation.
293list = list0 + list1; // Concatenation. Also works if either is not a list, it's promoted to a list first.
294list = (list=[]) + list + ["new_item"]; // Voodoo needed for old LSL, works in Mono but not needed, does not work in OS. Works for strings to.
295list == != // Only compares the lengths, probably applies to the other conditionals to.
296vector = vector0 + vector1; // Add elements together.
297vector = vector0 - vector1; // Subtract elements of vector1 from elements of vector0.
298float = vector0 * vector1; // A dot product of the vectors.
299vector = vector0 % vector1; // A cross product of the vectors.
300vector = vector * float; // Scale the vector, works the other way around I think.
301vector = vector * integer; // Scale the vector, works the other way around I think.
302vector = vector / float; // Scale the vector, works the other way around I think.
303vector = vector / integer; // Scale the vector, works the other way around I think.
304vector = vector * rotation; // Rotate the vector by the rotation. Other way around wont compile.
305vector = vector / rotation; // Rotate the vector by the rotation, in the opposite direction. Other way around wont compile.
306rotation = llGetRot() * rotation; // Rotate an object around the global axis.
307rotation = rotation * llGetLocalRot(); // Rotate an object around the local axis.
308rotation = rotation0 * rotation1; // Add two rotations, so the result is as if you applied each rotation one after the other.
309rotation = rotation0 + rotation1; // Similar to vector, but it's a meaningless thing as far as rotations go.
310rotation = 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