roblox-luau-mastery
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLuau Language Mastery (Index)
Luau语言精通(索引)
This skill has been split into three focused skills for better context efficiency. Load the one that matches your task:
为提升上下文效率,本技能已拆分为三个专注型技能。加载与你的任务匹配的技能即可:
Routing
路由
| Task | Load |
|---|---|
| Syntax, tables, control flow, string patterns, math, idioms, scope, closures, sharp edges, JS→Luau porting | |
| Type annotations, generics, narrowing, inference, strictness modes, exports, sealed/unsealed tables | |
| OOP (metatables, inheritance), async (Promises, pcall, coroutines), module structure, service pattern, Roblox idioms (Instance creation, events, task library) | |
| 任务 | 加载项 |
|---|---|
| 语法、表、控制流、字符串模式、数学运算、惯用写法、作用域、闭包、注意事项、JS→Luau移植 | |
| 类型注解、泛型、类型收窄、类型推断、严格模式、导出、密封/非密封表 | |
| 面向对象编程(元表、继承)、异步编程(Promises、pcall、协程)、模块结构、服务模式、Roblox惯用写法(实例创建、事件、任务库) | |
Quick Decision
快速选择
- "How do I write this in Luau?" →
roblox-luau-core - "How should I type this?" →
roblox-luau-types - "How should I structure this?" →
roblox-luau-patterns
- "如何用Luau编写这个?" →
roblox-luau-core - "如何为这个添加类型?" →
roblox-luau-types - "如何构建这个的结构?" →
roblox-luau-patterns
Key Rules (always apply)
核心规则(始终适用)
- Luau is NOT Lua 5.1. Has: generics, ,
continue, string interpolation (backticks), floor division+=// - Arrays are 1-based. for length. Generalized iteration:
#tblfor k, v in tbl do - Always use (never deprecated
task.wait/spawn/delay)wait/spawn/delay - Instance.new: configure properties THEN set Parent last (replication race)
- Services: at top of script, stored in locals
game:GetService("Name") - Methods: use (implicit self) for instance methods,
:for constructors/static. - Prefer backtick interpolation over concatenation
.. - Local function order: callees above callers (no hoisting)
- Only and
nilare falsyfalse
- Luau 不是 Lua 5.1。新增特性:泛型、、
continue、字符串插值(反引号)、地板除法+=// - 数组以1为起始索引。使用获取长度。通用迭代写法:
#tblfor k, v in tbl do - 始终使用(绝不要使用已废弃的
task.wait/spawn/delay)wait/spawn/delay - Instance.new:先配置属性,最后设置Parent(避免复制竞争)
- 服务:在脚本顶部使用,并存储在局部变量中
game:GetService("Name") - 方法:实例方法使用(隐式self),构造函数/静态方法使用
:. - 优先使用反引号插值,而非拼接
.. - 局部函数顺序:被调用函数放在调用函数上方(无变量提升)
- 仅和
nil为假值false