roblox-luau-mastery

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Luau 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

路由

TaskLoad
Syntax, tables, control flow, string patterns, math, idioms, scope, closures, sharp edges, JS→Luau porting
roblox-luau-core
Type annotations, generics, narrowing, inference, strictness modes, exports, sealed/unsealed tables
roblox-luau-types
OOP (metatables, inheritance), async (Promises, pcall, coroutines), module structure, service pattern, Roblox idioms (Instance creation, events, task library)
roblox-luau-patterns
任务加载项
语法、表、控制流、字符串模式、数学运算、惯用写法、作用域、闭包、注意事项、JS→Luau移植
roblox-luau-core
类型注解、泛型、类型收窄、类型推断、严格模式、导出、密封/非密封表
roblox-luau-types
面向对象编程(元表、继承)、异步编程(Promises、pcall、协程)、模块结构、服务模式、Roblox惯用写法(实例创建、事件、任务库)
roblox-luau-patterns

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.
    #tbl
    for length. Generalized iteration:
    for k, v in tbl do
  • Always use
    task.wait/spawn/delay
    (never deprecated
    wait/spawn/delay
    )
  • Instance.new: configure properties THEN set Parent last (replication race)
  • Services:
    game:GetService("Name")
    at top of script, stored in locals
  • Methods: use
    :
    (implicit self) for instance methods,
    .
    for constructors/static
  • Prefer backtick interpolation over
    ..
    concatenation
  • Local function order: callees above callers (no hoisting)
  • Only
    nil
    and
    false
    are falsy
  • Luau 不是 Lua 5.1。新增特性:泛型、
    continue
    +=
    、字符串插值(反引号)、地板除法
    //
  • 数组以1为起始索引。使用
    #tbl
    获取长度。通用迭代写法:
    for k, v in tbl do
  • 始终使用
    task.wait/spawn/delay
    (绝不要使用已废弃的
    wait/spawn/delay
  • Instance.new:先配置属性,最后设置Parent(避免复制竞争)
  • 服务:在脚本顶部使用
    game:GetService("Name")
    ,并存储在局部变量中
  • 方法:实例方法使用
    :
    (隐式self),构造函数/静态方法使用
    .
  • 优先使用反引号插值,而非
    ..
    拼接
  • 局部函数顺序:被调用函数放在调用函数上方(无变量提升)
  • nil
    false
    为假值