Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions src/content/docs/script/guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Welcome to the scripting guides! This section will provide in-depth tutorials an
</Card>

<Card title="Migration Guides" icon="forward">
Moving from LSL to SLua, common patterns, and differences
Moving from LSL to Lua, common patterns, and differences
</Card>

<Card title="Debugging & Testing" icon="magnifier">
Expand All @@ -53,5 +53,5 @@ While we build out these guides, you can:

- **Browse [Recipes](/script/recipes/)** - See working examples of common patterns
- **Check the [LSL Reference](/script/lsl-reference/)** - Complete LSL language documentation
- **Explore [Learn SLua](/script/learn-slua/)** - SLua language fundamentals
- **Explore [Learn Lua](/script/learn-Lua/)** - Lua language fundamentals
- **Visit the [Second Life Forums](https://community.secondlife.com/)** - Community support and discussions
8 changes: 4 additions & 4 deletions src/content/docs/script/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Getting Started with Scripting
description: Learn how to start scripting in Second Life with LSL and SLua
description: Learn how to start scripting in Second Life with Lua and LSL
---

import { Aside, Card, CardGrid } from '@astrojs/starlight/components';
Expand All @@ -16,8 +16,8 @@ Welcome to scripting in Second Life! Whether you're new to programming or an exp
Second Life supports two scripting languages:

<CardGrid>
<Card title="SLua (Second Life + Luau)" icon="rocket">
A modern scripting option based on Luau (A Lua variant). SLua brings contemporary language features to Second Life scripting.
<Card title="Lua in Second Life" icon="rocket">
A modern scripting option based on Luau (A Lua variant). Lua brings contemporary language features to Second Life scripting.

- Modern language features (maps, types, objects)
- Familiar to millions of Luau/Lua developers
Expand Down Expand Up @@ -47,7 +47,7 @@ Scripts control nearly every aspect of interactive content in Second Life:

Ready to start? Choose your path:

- **[Learn SLua](/script/learn-slua/)** - Explore SL's new scripting system
- **[Learn Lua](/script/learn-lua/)** - Explore SL's new scripting system
- **[Learn LSL](/script/lsl-reference/)** - Start with the classic language
- **[Browse Recipes](/script/recipes/)** - See practical examples and patterns

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Events
description: Event handling in SLua with LLEvents
description: Event handling in Lua with LLEvents
---

## Introduction

SLua uses the `LLEvents` system to handle events from the Second Life simulator. Unlike traditional event handler declarations, SLua allows you to register event handlers dynamically using callback functions, giving you more flexibility in how you structure your code.
Lua uses the `LLEvents` system to handle events from the Second Life simulator. Unlike traditional event handler declarations, Lua allows you to register event handlers dynamically using callback functions, giving you more flexibility in how you structure your code.

## Basic Event Registration

Expand Down Expand Up @@ -373,4 +373,4 @@ local listenHandler = LLEvents:on("listen", function(channel, name, id, msg)
end)
```

*This guide covers the LLEvents system for event handling in SLua. For timer management, see the [Timers](./timers/) documentation.*
*This guide covers the LLEvents system for event handling in Lua. For timer management, see the [Timers](./timers/) documentation.*
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
title: From LSL to SLua
description: Essential guide for LSL scripters transitioning to SLua
title: From LSL to Lua
description: Essential guide for LSL scripters transitioning to Lua
---

import { Aside } from '@astrojs/starlight/components';
import CodeComparison from '@components/CodeComparison.astro';

## For LSL Scripters

You already know how Second Life scripting works—events, permissions, object communication, inventory management. All of that knowledge transfers directly to SLua. This page focuses on the syntax and pattern differences you need to know.
You already know how Second Life scripting works—events, permissions, object communication, inventory management. All of that knowledge transfers directly to Lua. This page focuses on the syntax and pattern differences you need to know.

<Aside type="tip">
**LSL still works!** Your existing scripts continue to run, and LSL is fully supported. SLua is an option, not a requirement.
**LSL still works!** Your existing scripts continue to run, and LSL is fully supported. Lua is an option, not a requirement.
</Aside>

## Why Consider SLua?
## Why Consider Lua?

- **Faster execution** and **~50% less memory** than LSL/Mono
- **Modern features**: coroutines, gradual typing, multiple return values
Expand All @@ -35,7 +35,7 @@ You already know how Second Life scripting works—events, permissions, object c
integer x = 5; // Semicolons required
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
-- Single line comment
--[[ Multi-line
Expand All @@ -61,7 +61,7 @@ key uuid = "...";
list items = [1, 2, 3];
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
-- Dynamic typing with optional annotations
local health: number = 100
Expand All @@ -81,7 +81,7 @@ local items: {number} = {1, 2, 3} -- tables, not lists

### Operators

| Operation | LSL | SLua | Notes |
| Operation | LSL | Lua | Notes |
|-----------|-----|------|-------|
| Not equal | `!=` | `~=` | Different operator |
| Logical AND | `&&` | `and` | Word, not symbol |
Expand Down Expand Up @@ -124,7 +124,7 @@ do {
} while (count < 10);
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
-- if, then, else
if x > 5 then
Expand Down Expand Up @@ -166,7 +166,7 @@ float calculateDamage(float base, float mult) {
float result = calculateDamage(10.0, 1.5);
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
-- Always use type annotations
function calculateDamage(base: number, mult: number): number
Expand All @@ -185,7 +185,7 @@ local health: number, mana: number, status: string = getStats()

### Lists vs Tables

Tables are SLua's most powerful data structure. Unlike LSL's separate `list` type, tables serve **two purposes**: they work as both arrays (like LSL lists) and dictionaries/maps (which LSL doesn't have).
Tables are Lua's most powerful data structure. Unlike LSL's separate `list` type, tables serve **two purposes**: they work as both arrays (like LSL lists) and dictionaries/maps (which LSL doesn't have).

#### Tables as Arrays (LSL list replacement)

Expand All @@ -203,7 +203,7 @@ items += [50]; // Append
integer len = llListLength(items);
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
local items: {number} = {10, 20, 30, 40}

Expand All @@ -224,7 +224,7 @@ local len: number = #items

#### Tables as Dictionaries/Maps

LSL doesn't have a dictionary/map type—you had to use two parallel lists for key-value pairs. SLua tables can store key-value pairs natively:
LSL doesn't have a dictionary/map type—you had to use two parallel lists for key-value pairs. Lua tables can store key-value pairs natively:

```luau
-- Dictionary/map
Expand Down Expand Up @@ -297,7 +297,7 @@ integer len = llStringLength(msg);
string sub = llGetSubString(msg, 0, 4); // "Hello"
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
local msg: string = `Hello World`
local name: string = "Alice"
Expand All @@ -320,7 +320,7 @@ llSetRot(<0, 0, 0, 1>);
llGiveInventory(avatar, "Object");
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
ll.Say(0, "Hello")
ll.SetPos(vector(10, 20, 30))
Expand All @@ -334,7 +334,7 @@ ll.GiveInventory(avatar, "Object")

## Event Handling: The Big Change

This is the most significant difference between LSL and SLua. Instead of state-based event handlers, SLua uses **event callbacks** with `LLEvents:on()`.
This is the most significant difference between LSL and Lua. Instead of state-based event handlers, Lua uses **event callbacks** with `LLEvents:on()`.

<CodeComparison>
<Fragment slot="lsl">
Expand All @@ -357,7 +357,7 @@ default {
}
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
local clickCount: number = 0

Expand All @@ -375,7 +375,7 @@ end)
</Fragment>
</CodeComparison>

### SLua Event Patterns
### Lua Event Patterns

**Basic event handler:**
```luau
Expand Down Expand Up @@ -429,7 +429,7 @@ myFunction() {
}
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
-- Script-level variables (no 'local') are global
health = 100
Expand Down Expand Up @@ -473,7 +473,7 @@ default {
}
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
local isOpen: boolean = false
local closedPos: vector = ll.GetPos()
Expand Down Expand Up @@ -511,7 +511,7 @@ default {
}
```
</Fragment>
<Fragment slot="slua">
<Fragment slot="Lua">
```luau
local counter: number = 0

Expand Down Expand Up @@ -564,7 +564,7 @@ end

## Standard Libraries

SLua includes Lua standard libraries you can use alongside ll* functions. See the full [Luau library reference](https://luau.org/library) for more details.
Lua includes Lua standard libraries you can use alongside ll* functions. See the full [Luau library reference](https://luau.org/library) for more details.

```luau
-- String library
Expand All @@ -586,7 +586,7 @@ math.abs(-5) -- 5

## Next Steps

- **[SLua Basics](/script/learn/slua/basics/)** - Deep dive into the language
- **[SLua Events](/script/learn/slua/events/)** - Master event handling patterns
- **[SLua Reference](/script/reference/slua/functions/)** - All ll* functions
- **[SLua FAQ](https://wiki.secondlife.com/wiki/SLua_FAQ)** - Common questions
- **[Lua Basics](/script/learn/Lua/basics/)** - Deep dive into the language
- **[Lua Events](/script/learn/Lua/events/)** - Master event handling patterns
- **[Lua Reference](/script/reference/Lua/functions/)** - All ll* functions
- **[Lua FAQ](https://wiki.secondlife.com/wiki/Lua_FAQ)** - Common questions
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: Learn SLua
description: A comprehensive guide to scripting in Second Life with SLua (Luau)
title: Learn Lua
description: A comprehensive guide to scripting in Second Life with Lua (Luau)
---

import { Card, CardGrid, Tabs, TabItem } from '@astrojs/starlight/components';
import CodeComparison from '@components/CodeComparison.astro';

SLua brings modern scripting to Second Life using Luau, a high-performance typed variant of Lua developed by Roblox. If you're familiar with Lua, Python, JavaScript, or other modern languages, you'll feel right at home.
Lua brings modern scripting to Second Life using Luau, a high-performance typed variant of Lua developed by Roblox. If you're familiar with Lua, Python, JavaScript, or other modern languages, you'll feel right at home.

## Why SLua?
## Why Lua?

SLua offers several advantages for Second Life scripting:
Lua offers several advantages for Second Life scripting:

- **Modern Language Features** - coroutines, optional typing, objects, and more
- **Better Performance** - Optimized runtime for complex operations
Expand All @@ -20,7 +20,7 @@ SLua offers several advantages for Second Life scripting:

## Coming from LSL?

If you're already familiar with LSL, SLua will feel familiar but more powerful. Here's a quick comparison:
If you're already familiar with LSL, Lua will feel familiar but more powerful. Here's a quick comparison:

<CodeComparison>
<Fragment slot="lsl">
Expand Down Expand Up @@ -64,10 +64,10 @@ If you're already familiar with LSL, SLua will feel familiar but more powerful.
## What You'll Learn

:::note[Help Wanted]
We're building out comprehensive learning materials for SLua. These pages are planned but not yet available. If you'd like to contribute, check out our [GitHub repository](https://github.com/secondlife/create).
We're building out comprehensive learning materials for Lua. These pages are planned but not yet available. If you'd like to contribute, check out our [GitHub repository](https://github.com/secondlife/create).
:::

This guide will take you from SLua basics to advanced scripting:
This guide will take you from Lua basics to advanced scripting:

<CardGrid>
<Card title="Language Basics" icon="open-book">
Expand All @@ -91,13 +91,13 @@ This guide will take you from SLua basics to advanced scripting:
</Card>

<Card title="Migration Guide" icon="forward">
Convert your LSL scripts to SLua
Convert your LSL scripts to Lua
</Card>
</CardGrid>

## Quick Start

Let's write your first SLua script. This simple script makes an object say "Hello!" when touched:
Let's write your first Lua script. This simple script makes an object say "Hello!" when touched:

```luau
-- Listen for touch events
Expand All @@ -111,23 +111,23 @@ That's it! Save this script in a prim and touch it to see it work.

## Learning Path

Here's the recommended path through the SLua documentation:
Here's the recommended path through the Lua documentation:

1. **[Language Fundamentals](/script/learn/slua/fundamentals/)** - (HELP WANTED) Start here if you're new to SLua or Lua
2. **[From LSL to SLua](./from-lsl/)** - Converting your LSL knowledge to SLua
1. **[Language Fundamentals](/script/learn-lua/fundamentals/)** - (HELP WANTED) Start here if you're new to Lua
2. **[From LSL to Lua](./from-lsl/)** - Converting your LSL knowledge to Lua
3. **[Events and Handlers](./events/)** - (HELP WANTED) How to respond to world events
4. **[Async Programming](./async/)** - (HELP WANTED) Writing asynchronous code with coroutines
5. **[Working with Types](./types/)** - (HELP WANTED) Using SLua's optional type system
5. **[Working with Types](./types/)** - (HELP WANTED) Using Lua's optional type system
6. **[Standard Library](./library/)** - (HELP WANTED) Complete reference of available functions

## Resources

- **[SLua Function Reference](/script/slua-reference/)** - Complete API documentation
- **[Lua Function Reference](/script/lua-reference/)** - Complete API documentation
- **[Code Recipes](../recipes/)** - (HELP WANTED) Practical examples and patterns
- **[Suzanna's SLua Guide](https://suzanna-linn.github.io/slua/)** - Comprehensive external resource

## Need Help?

- Visit the [Second Life Forums](https://community.secondlife.com/) for community support
- Check the [recipes section](/script/recipes/) for working examples
- Review the [complete SLua reference](/script/reference/slua/) for detailed API documentation
- Review the [complete Lua reference](/script/lua-reference/) for detailed API documentation
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: JSON
description: JSON encoding and decoding in SLua with LLJSON
description: JSON encoding and decoding in Lua with LLJSON
---

## Introduction

SLua provides the `lljson` library for encoding Lua values to JSON strings and decoding JSON strings back to Lua values. This is essential for data serialization, HTTP requests, and communicating with external services.
Lua provides the `lljson` library for encoding Lua values to JSON strings and decoding JSON strings back to Lua values. This is essential for data serialization, HTTP requests, and communicating with external services.

## Basic Usage

Expand Down Expand Up @@ -600,7 +600,7 @@ end

## Summary

The `lljson` library provides robust JSON handling in SLua:
The `lljson` library provides robust JSON handling in Lua:

- Use `lljson.encode()` to convert Lua values to JSON
- Use `lljson.decode()` to parse JSON strings
Expand All @@ -615,4 +615,4 @@ JSON is the standard format for data exchange, making `lljson` essential for HTT

---

*This guide covers the LLJSON library for JSON encoding and decoding in SLua.*
*This guide covers the LLJSON library for JSON encoding and decoding in Lua.*
Loading
Loading