From 71f1dae8463b2b7f27e289e8a3258d6778f4581a Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Sat, 20 Dec 2025 13:06:30 -0800 Subject: [PATCH 1/6] Added a section about casting --- .../docs/script/learn-slua/from-lsl.mdx | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/content/docs/script/learn-slua/from-lsl.mdx b/src/content/docs/script/learn-slua/from-lsl.mdx index 95b27f7..cf94dfc 100644 --- a/src/content/docs/script/learn-slua/from-lsl.mdx +++ b/src/content/docs/script/learn-slua/from-lsl.mdx @@ -68,7 +68,7 @@ local health: number = 100 local damage: number = 25.5 local name: string = "Alice" local pos: vector = vector(10, 20, 30) -local rot: quaternion = quaternion(0, 0, 0, 1) +local rot: quaternion = quaternion(0, 0, 0, 1) -- also local rot: rotation = rotation(0, 0, 0, 1) local uuid: string = "..." -- keys are strings local items: {number} = {1, 2, 3} -- tables, not lists ``` @@ -79,6 +79,33 @@ local items: {number} = {1, 2, 3} -- tables, not lists **Type annotations recommended!** While optional, they catch errors before runtime and make code self-documenting. +#### Casting +In many cases, luau does casting automatically. Here's how to do it manually: + + +```lsl +(integer)"-4.4"; +(float)"25.5"; +(string)99.9; +(vector)"<10, 20, 30>"; +(rotation)"<0, 0, 0, 1>"; +(key)"700843d3-0d15-c427-81ab-e9c8a0dcdb1e"; +(list)"hello"; // equivilant to ["hello"] +``` + + +```luau +(math.modf("-4.4")) -- extra parentheses are necessary to discard the second return value +tonumber("25.5") +tostring(99.9) +tovector("<10, 20, 30>") +torotation("<0, 0, 0, 1>") -- also toquaternion("<0, 0, 0, 1>") +"700843d3-0d15-c427-81ab-e9c8a0dcdb1e" -- keys are strings +{"hello"} -- table, not list +``` + + + ### Operators | Operation | LSL | SLua | Notes | From 528d973832f0e65d1c972deb6409249bdf9434c1 Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Sat, 20 Dec 2025 16:47:22 -0800 Subject: [PATCH 2/6] Casting -> Typecasting --- src/content/docs/script/learn-slua/from-lsl.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/script/learn-slua/from-lsl.mdx b/src/content/docs/script/learn-slua/from-lsl.mdx index cf94dfc..53c59de 100644 --- a/src/content/docs/script/learn-slua/from-lsl.mdx +++ b/src/content/docs/script/learn-slua/from-lsl.mdx @@ -79,8 +79,8 @@ local items: {number} = {1, 2, 3} -- tables, not lists **Type annotations recommended!** While optional, they catch errors before runtime and make code self-documenting. -#### Casting -In many cases, luau does casting automatically. Here's how to do it manually: +#### Typecasting +In many cases, luau does typecasting automatically. Here's how to do it explicitly: ```lsl From 9147d4c20c9bb7b7e89b82a163d5c5fd83143e25 Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Sat, 20 Dec 2025 23:23:54 -0800 Subject: [PATCH 3/6] noted that uuid and string are no longer interchangable --- src/content/docs/script/learn-slua/from-lsl.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/docs/script/learn-slua/from-lsl.mdx b/src/content/docs/script/learn-slua/from-lsl.mdx index 53c59de..bab383e 100644 --- a/src/content/docs/script/learn-slua/from-lsl.mdx +++ b/src/content/docs/script/learn-slua/from-lsl.mdx @@ -57,7 +57,7 @@ float damage = 25.5; string name = "Alice"; vector pos = <10, 20, 30>; rotation rot = <0, 0, 0, 1>; -key uuid = "..."; +key k = "..."; list items = [1, 2, 3]; ``` @@ -68,8 +68,8 @@ local health: number = 100 local damage: number = 25.5 local name: string = "Alice" local pos: vector = vector(10, 20, 30) -local rot: quaternion = quaternion(0, 0, 0, 1) -- also local rot: rotation = rotation(0, 0, 0, 1) -local uuid: string = "..." -- keys are strings +local rot: quaternion = quaternion(0, 0, 0, 1) +local k: uuid = uuid("...") local items: {number} = {1, 2, 3} -- tables, not lists ``` @@ -95,12 +95,12 @@ In many cases, luau does typecasting automatically. Here's how to do it explicit ```luau -(math.modf("-4.4")) -- extra parentheses are necessary to discard the second return value +(math.modf("-4.4")) -- extra parentheses are necessary tonumber("25.5") tostring(99.9) tovector("<10, 20, 30>") -torotation("<0, 0, 0, 1>") -- also toquaternion("<0, 0, 0, 1>") -"700843d3-0d15-c427-81ab-e9c8a0dcdb1e" -- keys are strings +toquaternion("<0, 0, 0, 1>") +uuid("700843d3-0d15-c427-81ab-e9c8a0dcdb1e") {"hello"} -- table, not list ``` From 4da71c8ec083ed85e7f3f70c153ddea5e01ac5c2 Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Wed, 7 Jan 2026 14:50:38 -0800 Subject: [PATCH 4/6] Clarify parentheses necessity in math.modf example --- src/content/docs/script/learn-slua/from-lsl.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/script/learn-slua/from-lsl.mdx b/src/content/docs/script/learn-slua/from-lsl.mdx index bab383e..39ba74e 100644 --- a/src/content/docs/script/learn-slua/from-lsl.mdx +++ b/src/content/docs/script/learn-slua/from-lsl.mdx @@ -95,7 +95,7 @@ In many cases, luau does typecasting automatically. Here's how to do it explicit ```luau -(math.modf("-4.4")) -- extra parentheses are necessary +(math.modf("-4.4")) -- extra parentheses sometimes necessary tonumber("25.5") tostring(99.9) tovector("<10, 20, 30>") From e8dbef34260a7a57a7aed591f6c9106c419085f7 Mon Sep 17 00:00:00 2001 From: Tapple Gao Date: Wed, 7 Jan 2026 16:45:08 -0800 Subject: [PATCH 5/6] Add or expressions to convert nil to the LSL typecast value --- src/content/docs/script/learn-slua/from-lsl.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/content/docs/script/learn-slua/from-lsl.mdx b/src/content/docs/script/learn-slua/from-lsl.mdx index 39ba74e..8458122 100644 --- a/src/content/docs/script/learn-slua/from-lsl.mdx +++ b/src/content/docs/script/learn-slua/from-lsl.mdx @@ -95,16 +95,17 @@ In many cases, luau does typecasting automatically. Here's how to do it explicit ```luau -(math.modf("-4.4")) -- extra parentheses sometimes necessary -tonumber("25.5") +(math.modf(tonumber("-4.4") or 0)) -- extra parentheses sometimes necessary +tonumber("25.5") or 0 tostring(99.9) -tovector("<10, 20, 30>") -toquaternion("<0, 0, 0, 1>") -uuid("700843d3-0d15-c427-81ab-e9c8a0dcdb1e") +tovector("<10, 20, 30>") or ZERO_VECTOR +toquaternion("<0, 0, 0, 1>") or ZERO_ROTATION +uuid("700843d3-0d15-c427-81ab-e9c8a0dcdb1e") or NULL_KEY {"hello"} -- table, not list ``` +LSL and Lua typecasts return different results on invalid input: LSL returns "zero"; lua returns `nil`. The Lua examples include an `or` expressions that converts `nil` to what LSL typecast would have returned ### Operators From bdb42071146c7ff6bb309ca28ab4a14dbed1c44e Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 30 Apr 2026 21:14:34 -0700 Subject: [PATCH 6/6] consistently capitalize LSL and Lua --- .../docs/script/learn-lua/from-lsl.mdx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/content/docs/script/learn-lua/from-lsl.mdx b/src/content/docs/script/learn-lua/from-lsl.mdx index 6b09430..ce2e753 100644 --- a/src/content/docs/script/learn-lua/from-lsl.mdx +++ b/src/content/docs/script/learn-lua/from-lsl.mdx @@ -26,7 +26,7 @@ You already know how Second Life scripting works—events, permissions, object c ### Comments & Structure - + ```lsl // Single line comment /* Multi-line @@ -49,7 +49,7 @@ local x: number = 5 -- Semicolons optional (rarely used) ### Variables & Types - + ```lsl // Type declarations required integer health = 100; @@ -80,9 +80,9 @@ local items: {number} = {1, 2, 3} -- tables, not lists #### Typecasting -In many cases, luau does typecasting automatically. Here's how to do it explicitly: +In many cases, Luau does typecasting automatically. Here's how to do it explicitly: - + ```lsl (integer)"-4.4"; (float)"25.5"; @@ -93,7 +93,7 @@ In many cases, luau does typecasting automatically. Here's how to do it explicit (list)"hello"; // equivilant to ["hello"] ``` - + ```luau (math.modf(tonumber("-4.4") or 0)) -- extra parentheses sometimes necessary tonumber("25.5") or 0 @@ -105,7 +105,7 @@ uuid("700843d3-0d15-c427-81ab-e9c8a0dcdb1e") or NULL_KEY ``` -LSL and Lua typecasts return different results on invalid input: LSL returns "zero"; lua returns `nil`. The Lua examples include an `or` expressions that converts `nil` to what LSL typecast would have returned +LSL and Lua typecasts return different results on invalid input: LSL returns "zero"; Lua returns `nil`. The Lua examples include an `or` expressions that converts `nil` to what LSL typecast would have returned ### Operators @@ -125,7 +125,7 @@ LSL and Lua typecasts return different results on invalid input: LSL returns "ze ### Control Flow - + ```lsl // if, then, else if (x > 5) { @@ -184,7 +184,7 @@ until count >= 10 ### Functions - + ```lsl float calculateDamage(float base, float mult) { return base * mult; @@ -218,7 +218,7 @@ Tables are Lua's most powerful data structure. Unlike LSL's separate `list` type #### Tables as Arrays (LSL list replacement) - + ```lsl list items = [10, 20, 30, 40]; @@ -315,7 +315,7 @@ ll.Say(0, `Name: {data.name}`) -- "Alice" ### String Operations - + ```lsl string msg = "Hello" + " " + "World"; string name = "Alice"; @@ -340,7 +340,7 @@ local sub: string = string.sub(msg, 1, 5) -- "Hello" (1-based!) ### ll* Functions - + ```lsl llSay(0, "Hello"); llSetPos(<10, 20, 30>); @@ -365,7 +365,7 @@ ll.GiveInventory(avatar, "Object") This is the most significant difference between LSL and Lua. Instead of state-based event handlers, Lua uses **event callbacks** with `LLEvents:on()`. - + ```lsl integer clickCount = 0; @@ -446,7 +446,7 @@ end) ## Global Variables - + ```lsl // All script-level variables are global integer health = 100; @@ -477,7 +477,7 @@ end ### Door Script - + ```lsl integer isOpen = FALSE; vector closedPos; @@ -523,7 +523,7 @@ end) ### Timer Events - + ```lsl integer counter = 0;