msw-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MSW Search

MSW 搜索

MSW has two distinct search targets. They behave differently, so they are covered in separate sections.
  1. API docs & implementation guides — Vector search that provides the details, code examples, related APIs, and implementation guidance that
    .d.mlua
    lacks.
  2. Resources — REST API to search and browse sprites, animations, sounds, resource packs, and avatars. The only path for obtaining RUIDs.

MSW 拥有两种不同的搜索目标,它们的行为逻辑不同,因此分为单独章节介绍。
  1. API 文档与实现指南 — 向量搜索,可提供 .d.mlua 中缺失的细节、代码示例、相关 API 及实现指导。
  2. 资源 — REST API,用于搜索和浏览 sprites、animations、sounds、resource packs 和 avatars,是获取 RUID 的唯一途径。

Routing Table

路由表

Request typeGo to section
"How do I implement this?", "Show me an example", "What related APIs exist?"Document search
".d.mlua only has the signature; the description is insufficient"Document search
"I don't know the API name (semantic search)"Document search (
type=both
)
"Implementation guide / best practice / pattern"Document search (
type=document
)
"I need a SpriteRUID", "Find a sprite for monster / NPC / background"Resource search
"Find an animation / sound / resource pack"Resource search
"Details for this RUID", "Similar resources"Resource search
"Avatar rendering / default avatar"Resource search

请求类型跳转章节
"如何实现这个功能?"、"给我看示例"、"有哪些相关 API?"文档搜索
".d.mlua 仅包含签名,描述信息不足"文档搜索
"我不知道 API 名称(语义搜索)"文档搜索(
type=both
"实现指南 / 最佳实践 / 设计模式"文档搜索(
type=document
"我需要 SpriteRUID"、"查找怪物/NPC/背景的 sprite"资源搜索
"查找动画/音效/资源包"资源搜索
"该 RUID 的详情"、"相似资源"资源搜索
"头像渲染 / 默认头像"资源搜索

Section 1 — Document Search (APIs & Guides)

章节一 — 文档搜索(API 与指南)

Vector search that supplies the detailed descriptions, code examples, related APIs, and implementation guides missing from
.d.mlua
.
向量搜索,可补充
.d.mlua
缺失的详细描述、代码示例、相关 API 及实现指南

Access Methods

访问方式

The same vector search backend can be accessed through two paths. Results are identical.
MethodConditionUsage
MCP tool
msw-guide-mcp
is connected
Call
mlua_Document_Retriever
,
mlua_API_Retriever
Direct curlFallback when MCP is not connected
curl "http://10.10.200.51:31817/search?q=...&type=...&limit=..."
同一向量搜索后端可通过两种途径访问,搜索结果完全一致
方式条件使用方法
MCP 工具已连接
msw-guide-mcp
调用
mlua_Document_Retriever
mlua_API_Retriever
直接 curl 请求MCP 未连接时的备选方案
curl "http://10.10.200.51:31817/search?q=...&type=...&limit=..."

Decision Flow

决策流程

Need API-related information
├─ Checking signature / type / property / enum
│   → Read .d.mlua first (highest priority)
│   → If .d.mlua is insufficient, use vector search
│     (code examples, parameter details, related APIs, etc.)
├─ Implementation guide / pattern / best practice
│   → Vector search (type=document)
├─ Don't know the API name (semantic search)
│   → Vector search (type=both)
└─ How to access vector search:
    ├─ msw-guide-mcp connected? → MCP tool
    └─ Not connected → curl

需要 API 相关信息
├─ 检查签名 / 类型 / 属性 / 枚举
│   → 优先查看 .d.mlua
│   → 若 .d.mlua 信息不足,使用向量搜索
│     (代码示例、参数细节、相关 API 等)
├─ 实现指南 / 设计模式 / 最佳实践
│   → 向量搜索(type=document)
├─ 不知道 API 名称(语义搜索)
│   → 向量搜索(type=both)
└─ 如何访问向量搜索:
    ├─ 是否已连接 msw-guide-mcp?→ 使用 MCP 工具
    └─ 未连接 → 使用 curl

API Research Order

API 调研优先级

Priority 1 — .d.mlua (always first)

优先级 1 — .d.mlua(始终优先)

If you know the API name, always read
.d.mlua
first.
Signatures, types, properties, event parameters, and enum values can be confirmed here accurately.
Path:
Environment/NativeScripts/{Component,Service,Event,Enum,Logic,Misc}/Name.d.mlua
SituationExample
Confirm method signature"Does TransformComponent have SetPosition?"
Property type / existence"What is the type of SpriteRendererComponent.RUID?"
Event parameter structure"What are the AttackEvent constructor parameters?"
List of enum values"What are the BodyMoveType values?"
Method existence"What methods does SpawnService have?"
若已知 API 名称,务必先查看
.d.mlua
。签名、类型、属性、事件参数及枚举值均可在此准确确认。
路径
Environment/NativeScripts/{Component,Service,Event,Enum,Logic,Misc}/Name.d.mlua
场景示例
确认方法签名"TransformComponent 是否有 SetPosition 方法?"
属性类型 / 存在性"SpriteRendererComponent.RUID 的类型是什么?"
事件参数结构"AttackEvent 的构造函数参数有哪些?"
枚举值列表"BodyMoveType 的取值有哪些?"
方法存在性"SpawnService 有哪些方法?"

Priority 2 — Vector search (when .d.mlua is not enough)

优先级 2 — 向量搜索(.d.mlua 信息不足时)

.d.mlua
contains only signatures and lacks detailed descriptions and examples. Use vector search when you need any of the following.
SituationSearch typeExample query
Need a code example
api
AIComponent example
,
BehaviorTree usage
Parameter details
api
BadgeService GetBadgeInfosAndWait parameters
Related API cross-references
api
AttackComponent related
,
HitComponent
ScriptOverridable check
api
AttackComponent CalcCritical override
Don't know the API name
both
damage calculation
,
inventory save
"How do I …?" implementation guide
document
how to make inventory system
Pattern / best practice
document
collision detection best practice
MCP mapping:
mlua_API_Retriever
=
type=api
,
mlua_Document_Retriever
=
type=document
.

.d.mlua
仅包含签名,缺少详细描述和示例。当需要以下信息时,使用向量搜索:
场景搜索类型查询示例
需要代码示例
api
AIComponent example
BehaviorTree usage
参数细节
api
BadgeService GetBadgeInfosAndWait parameters
相关 API 交叉引用
api
AttackComponent related
HitComponent
ScriptOverridable 检查
api
AttackComponent CalcCritical override
不知道 API 名称
both
damage calculation
inventory save
“如何实现……?” 类实现指南
document
how to make inventory system
设计模式 / 最佳实践
document
collision detection best practice
MCP 映射关系:
mlua_API_Retriever
=
type=api
mlua_Document_Retriever
=
type=document

MCP Tool Usage

MCP 工具使用方法

When
msw-guide-mcp
is connected:
ToolMaps to typeDescription
mlua_API_Retriever
api
API details for Service / Component / Misc etc. (signatures, parameters, examples)
mlua_Document_Retriever
document
Authoring manuals, guidelines, MLua usage, and other document-style material
Tool names and parameters follow the latest MCP schema.
Connection check: If a tool call errors out, it is not connected — fall back to curl.

当已连接
msw-guide-mcp
时:
工具对应类型描述
mlua_API_Retriever
api
服务/组件/杂项等的 API 详情(签名、参数、示例)
mlua_Document_Retriever
document
创作手册、指南、MLua 使用说明及其他文档类内容
工具名称和参数遵循最新 MCP 规范
连接检查:若工具调用报错,则说明未连接,需切换至 curl 请求。

Direct curl Usage

直接 curl 请求使用方法

When
msw-guide-mcp
is not connected:
GET http://10.10.200.51:31817/search?q={query}&type={type}&limit={limit}
ParameterRequiredValueDescription
q
OstringSearch query (natural language or API name)
type
X
api
|
document
|
both
Search scope (default:
both
)
limit
XintegerMax results (default: 5)
当未连接
msw-guide-mcp
时:
GET http://10.10.200.51:31817/search?q={query}&type={type}&limit={limit}
参数必填取值描述
q
string搜索查询(自然语言或 API 名称)
type
api
|
document
|
both
搜索范围(默认值:
both
limit
integer最大结果数(默认值:5)

How to choose
type

如何选择
type

Intenttype
Specific API spec (parameters, return type, example)
api
Implementation guidance (how-to, tutorial, concept)
document
Ambiguous or broad scope
both
意图type
特定 API 规范(参数、返回类型、示例)
api
实现指导(操作步骤、教程、概念)
document
模糊或宽泛的搜索范围
both

Usage Examples

使用示例

bash
undefined
bash
undefined

Specific API details + example

特定 API 详情 + 示例

Implementation guide

实现指南

Semantic search (when exact API name is unknown)

语义搜索(未知确切 API 名称时)

Response Format

响应格式

json
{
  "results": "formatted text with matching documents (title, section, content)"
}
json
{
  "results": "包含匹配文档的格式化文本(标题、章节、内容)"
}

Error Handling

错误处理

CodeMeaningAction
503
Service is starting upRetry after a short wait
500
Internal error (OpenSearch)Fall back to
.d.mlua
files
Connection failureService not runningFall back to
.d.mlua
files

状态码含义处理方式
503
服务正在启动稍作等待后重试
500
内部错误(OpenSearch)退而查看
.d.mlua
文件
连接失败服务未运行退而查看
.d.mlua
文件

.d.mlua vs Search — Information Comparison

.d.mlua 与搜索的信息对比

.d.mlua
is a type stub (~29 lines); Search returns the full document (254+ lines).
Information.d.mluaSearch
Method signature / typesOO
Property declarationsOO
Detailed method description (DetailDesc)XO
Code examples (AdditionalPageContent)XO
Per-parameter descriptionsXO
Related APIs (SeeAlsoAPIs)XO
Related guides (SeeAlsoGuides)XO
ScriptOverridable flagXO
SyncDirectionPartialO
Localized descriptions (Ko/Ja/Es/Zh)XO

.d.mlua
是类型存根文件(约 29 行);搜索返回完整文档(254+ 行)。
信息类型.d.mlua搜索
方法签名 / 类型
属性声明
详细方法描述(DetailDesc)
代码示例(AdditionalPageContent)
逐参数描述
相关 API(SeeAlsoAPIs)
相关指南(SeeAlsoGuides)
ScriptOverridable 标记
SyncDirection部分支持
多语言描述(韩/日/西/中)

Maker Editor Syntax → .mlua Conversion Rules

Maker Editor 语法 → .mlua 转换规则

Code examples in search results use Maker Editor syntax. They must be converted before being used in a local
.mlua
file.
ItemMaker Editor.mlua fileNote
Override declaration
override integer CalcDamage(...)
method integer CalcDamage(...)
override
method
Block
{ ... }
... end
Braces →
end
Exec space
[server only]
or omitted
@ExecSpace("ServerOnly")
Annotation must be explicit
Property
Property: int32 Score = 0
@Sync property int32 Score = 0
Add
@Sync
if synced
Type
int
int
integer
C# int → mlua integer
Type
number
number
number
Same (double)
Type
float
float
float
Same (single)
number
(64-bit double) and
float
(32-bit single) are assignable to each other but remain distinct types. Follow the
.d.mlua
declaration.
Conversion example — AttackComponent from search results:
-- Maker Editor syntax (search result)
override int CalcDamage(Entity attacker, Entity defender, string attackInfo) {
    return 50
}
override boolean CalcCritical(Entity attacker, Entity defender, string attackInfo) {
    return _UtilLogic:RandomDouble() < 0.3
}
lua
-- Converted to .mlua
@ExecSpace("ServerOnly")
method integer CalcDamage(Entity attacker, Entity defender, string attackInfo)
    return 50
end

@ExecSpace("ServerOnly")
method boolean CalcCritical(Entity attacker, Entity defender, string attackInfo)
    return _UtilLogic:RandomDouble() < 0.3
end

搜索结果中的代码示例使用Maker Editor 语法,需转换后才能在本地
.mlua
文件中使用。
Maker Editor.mlua 文件说明
重写声明
override integer CalcDamage(...)
method integer CalcDamage(...)
override
替换为
method
代码块
{ ... }
... end
大括号替换为
end
执行空间
[server only]
或省略
@ExecSpace("ServerOnly")
必须显式添加注解
属性
Property: int32 Score = 0
@Sync property int32 Score = 0
若为同步属性需添加
@Sync
类型
int
int
integer
C# int 转换为 mlua integer
类型
number
number
number
保持一致(双精度)
类型
float
float
float
保持一致(单精度)
number
(64 位双精度)和
float
(32 位单精度)可相互赋值,但属于不同类型,请遵循
.d.mlua
中的声明。
转换示例 — 搜索结果中的 AttackComponent:
-- Maker Editor 语法(搜索结果)
override int CalcDamage(Entity attacker, Entity defender, string attackInfo) {
    return 50
}
override boolean CalcCritical(Entity attacker, Entity defender, string attackInfo) {
    return _UtilLogic:RandomDouble() < 0.3
}
lua
-- 转换为 .mlua
@ExecSpace("ServerOnly")
method integer CalcDamage(Entity attacker, Entity defender, string attackInfo)
    return 50
end

@ExecSpace("ServerOnly")
method boolean CalcCritical(Entity attacker, Entity defender, string attackInfo)
    return _UtilLogic:RandomDouble() < 0.3
end

Section 2 — Resource Search (Sprite / Animation / Sound / Resource Pack / Avatar)

章节二 — 资源搜索(Sprite / Animation / Sound / Resource Pack / Avatar)

REST API for searching and browsing MSW resources. Never guess or fabricate a RUID — always obtain one through this API.
用于搜索和浏览 MSW 资源的 REST API。切勿猜测或编造 RUID — 务必通过此 API 获取

Base URL

基础 URL

https://resourcesearch-api.future.msw.nxdev.kr
  • No authentication (public API)
  • All endpoints use the
    /v3/
    prefix
  • Content-Type:
    application/json; charset=utf-8
    (for POST requests)
  • Recommended timeout: 15 seconds
https://resourcesearch-api.future.msw.nxdev.kr
  • 无需身份验证(公开 API)
  • 所有端点均使用
    /v3/
    前缀
  • Content-Type:
    application/json; charset=utf-8
    (POST 请求)
  • 推荐超时时间:15 秒

POST body rule — always use a temp file, never inline
-d '...'

POST 请求体规则 — 务必使用临时文件,切勿直接内联
-d '...'

For every POST endpoint in this section (
/v3/search/resources
,
/v3/resources/batch
,
/v3/avatar/render
), write the JSON body to a temp file first and call curl with
--data-binary "@file"
:
bash
REQ="$TMPDIR/msw_req.json"
cat > "$REQ" <<'JSON'
{ "query": "주황버섯", "types": ["resource_pack"], "categories": ["mob"], "limit": 5 }
JSON

curl -s -X POST https://resourcesearch-api.future.msw.nxdev.kr/v3/search/resources \
  -H "Content-Type: application/json; charset=utf-8" \
  --data-binary "@$REQ"
Why: passing JSON inline (
-d '{"query":"주황버섯",...}'
) frequently breaks on non-ASCII input (Korean / Japanese / Chinese / emoji). The shell re-encodes the argument and the server returns:
{ "detail": "There was an error parsing the body" }
The temp-file pattern also sidesteps the extra quoting/escaping required on Windows (PowerShell, Git Bash). Apply it uniformly even when the body is ASCII-only, so the recipe stays identical across platforms and languages.
On Windows PowerShell, use
$env:TEMP\msw_req.json
instead of
$TMPDIR/msw_req.json
and write the file with
Set-Content -Encoding utf8
(or
Out-File -Encoding utf8
). The
--data-binary "@file"
part is unchanged.
对于本节中的所有 POST 端点
/v3/search/resources
/v3/resources/batch
/v3/avatar/render
),需先将 JSON 请求体写入临时文件,再通过
--data-binary "@file"
调用 curl:
bash
REQ="$TMPDIR/msw_req.json"
cat > "$REQ" <<'JSON'
{ "query": "주황버섯", "types": ["resource_pack"], "categories": ["mob"], "limit": 5 }
JSON

curl -s -X POST https://resourcesearch-api.future.msw.nxdev.kr/v3/search/resources \
  -H "Content-Type: application/json; charset=utf-8" \
  --data-binary "@$REQ"
原因:直接内联 JSON(
-d '{"query":"주황버섯",...}'
)在处理非 ASCII 输入(韩文/日文/中文/表情符号)时经常出错。Shell 会重新编码参数,导致服务器返回:
{ "detail": "There was an error parsing the body" }
临时文件模式还能避免 Windows(PowerShell、Git Bash)下额外的引号/转义操作。即使请求体仅包含 ASCII 字符,也建议统一使用此模式,确保跨平台和跨语言的操作流程一致。
在 Windows PowerShell 中,使用
$env:TEMP\msw_req.json
替代
$TMPDIR/msw_req.json
,并通过
Set-Content -Encoding utf8
(或
Out-File -Encoding utf8
)写入文件。
--data-binary "@file"
部分保持不变。

Resource Types

资源类型

typeDescription
sprite
Static image (PNG)
animationclip
Frame-based animation
resource_pack
Finished asset bundling sprites + animations + sounds
sound
Sound / audio clip
type描述
sprite
静态图片(PNG)
animationclip
逐帧动画
resource_pack
包含 sprite + 动画 + 音效的成品资源包
sound
音效/音频片段

Categories

分类

categoryDescription
mob
Monster
npc
NPC
map
Map / background / terrain
item
Item
effect
Effect
skill
Skill
ui
UI element
category描述
mob
怪物
npc
NPC
map
地图/背景/地形
item
物品
effect
特效
skill
技能
ui
UI 元素

RUID

RUID

A 32-character hex string that uniquely identifies every resource. Example:
"0017da7385e04bc4b2ddbe5949b4b462"
  • The
    id
    field in search results is the RUID
  • assetGuid
    is a separate Unity asset GUID (used in
    spawn_preset
    )
  • Never guess or fabricate a RUID — always obtain it from an API response
唯一标识每个资源的 32 位十六进制字符串。示例:
"0017da7385e04bc4b2ddbe5949b4b462"
  • 搜索结果中的
    id
    字段即为 RUID
  • assetGuid
    是独立的 Unity 资源 GUID(用于
    spawn_preset
  • 切勿猜测或编造 RUID,务必从 API 响应中获取

Common Response Fields

通用响应字段

json
{
  "id": "32-char hex RUID",
  "type": "sprite|animationclip|resource_pack|sound",
  "category": "mob|npc|map|item|effect|skill|ui",
  "names": {
    "ko": ["Korean name"],
    "en": ["English name"]
  },
  "assetGuid": "Unity asset GUID (may or may not exist)",
  "payload": {
    "width": 64,
    "height": 64,
    "thumbnail": "https://...",
    "pivot": {"x": 32, "y": 32},
    "frames": [],
    "elements": []
  }
}
json
{
  "id": "32-char hex RUID",
  "type": "sprite|animationclip|resource_pack|sound",
  "category": "mob|npc|map|item|effect|skill|ui",
  "names": {
    "ko": ["Korean name"],
    "en": ["English name"]
  },
  "assetGuid": "Unity asset GUID (may or may not exist)",
  "payload": {
    "width": 64,
    "height": 64,
    "thumbnail": "https://...",
    "pivot": {"x": 32, "y": 32},
    "frames": [],
    "elements": []
  }
}

Endpoint Summary

端点汇总

MethodEndpointPurpose
POST
/v3/search/resources
Natural-language semantic search
GET
/v3/search/resources/similar/{ruid}
Find similar resources
GET
/v3/resources/{ruid}
Single resource details
POST
/v3/resources/batch
Batch fetch multiple resources
GET
/v3/resources/tags/{ruid}
AI-generated multilingual tags
GET
/v3/resources
List by type / category
GET
/v3/resources/random
Random resource recommendation
GET
/v3/resources/packs/{pack_id}
Resource pack details + components
GET
/v3/avatars/defaults
Default avatar body / head RUIDs
GET
/v3/avatars/{ruid}
Avatar item details
POST
/v3/avatar/render
Render an avatar

方法端点用途
POST
/v3/search/resources
自然语言语义搜索
GET
/v3/search/resources/similar/{ruid}
查找相似资源
GET
/v3/resources/{ruid}
单个资源详情
POST
/v3/resources/batch
批量获取多个资源
GET
/v3/resources/tags/{ruid}
AI 生成的多语言标签
GET
/v3/resources
按类型/分类列出资源
GET
/v3/resources/random
随机推荐资源
GET
/v3/resources/packs/{pack_id}
资源包详情及组件
GET
/v3/avatars/defaults
默认头像身体/头部 RUID
GET
/v3/avatars/{ruid}
头像物品详情
POST
/v3/avatar/render
渲染头像

Resource Routing Guide

资源路由指南

SituationEndpoint to useReference file
"Find a slime sprite"
POST /v3/search/resources
references/resource/search.md
"Any more monsters like this one?"
GET /v3/search/resources/similar/{ruid}
references/resource/search.md
"Details for RUID abc123"
GET /v3/resources/{ruid}
references/resource/detail.md
"Show me a list of monster sprites"
GET /v3/resources
references/resource/browse.md
"What's inside this resource pack?"
GET /v3/resources/packs/{pack_id}
references/resource/browse.md
"Render an avatar"
POST /v3/avatar/render
references/resource/avatar.md
场景使用端点参考文档
"查找史莱姆 sprite"
POST /v3/search/resources
references/resource/search.md
"有没有和这个怪物类似的资源?"
GET /v3/search/resources/similar/{ruid}
references/resource/search.md
"RUID abc123 的详情"
GET /v3/resources/{ruid}
references/resource/detail.md
"列出所有怪物 sprite"
GET /v3/resources
references/resource/browse.md
"这个资源包里有什么内容?"
GET /v3/resources/packs/{pack_id}
references/resource/browse.md
"渲染头像"
POST /v3/avatar/render
references/resource/avatar.md

Typical Workflow

典型工作流程

1. Semantic search (POST /v3/search/resources) → obtain RUID
2. Detail lookup (GET /v3/resources/{ruid}) → inspect payload
3. For resource packs → pack details (GET /v3/resources/packs/{pack_id}) → individual element RUIDs
4. Assign the individual RUID to SpriteRendererComponent.SpriteRUID
For detailed Request/Response of each endpoint, refer to the files under
references/resource/
.

1. 语义搜索(POST /v3/search/resources)→ 获取 RUID
2. 详情查询(GET /v3/resources/{ruid})→ 查看 payload
3. 若为资源包 → 查看资源包详情(GET /v3/resources/packs/{pack_id})→ 获取单个元素的 RUID
4. 将单个元素的 RUID 赋值给 SpriteRendererComponent.SpriteRUID
各端点的详细请求/响应格式,请参考
references/resource/
下的文档。

Shared Tips

通用技巧

  1. Keyword choice — Use the exact name if you know it; natural-language Korean/English also works.
  2. Adjust
    limit
    — Use a larger value (10+) for broad exploration, smaller (3) for precise lookups.
  3. When search fails:
    • Document search fails → read
      .d.mlua
      directly and check
      mod/APIMetadata/
      JSON.
    • Resource search fails → retry with synonyms or a different category; browse with
      GET /v3/resources
      by type/category.
    • POST
      returns
      {"detail":"There was an error parsing the body"}
      → you almost certainly used inline
      -d '{...}'
      with a non-ASCII value. Switch to the temp-file pattern (
      --data-binary "@file"
      ) described in Section 2.
  4. Composite queries are allowed — e.g.
    AttackComponent CalcCritical
    for docs,
    red slime jump
    for resources.
  5. No guessing — Never guess API names, RUIDs, or enum values; always confirm via search or references.
  1. 关键词选择:若已知确切名称则使用;自然语言(韩文/英文)同样有效。
  2. 调整
    limit
    :宽泛探索时使用较大值(10+),精准查找时使用较小值(3)。
  3. 搜索失败时
    • 文档搜索失败 → 直接查看
      .d.mlua
      并检查
      mod/APIMetadata/
      下的 JSON 文件。
    • 资源搜索失败 → 使用同义词或更换分类重试;通过
      GET /v3/resources
      按类型/分类浏览。
    • POST 请求返回
      {"detail":"There was an error parsing the body"}
      → 几乎可以肯定是使用了包含非 ASCII 值的内联
      -d '{...}'
      ,请切换至章节二中描述的临时文件模式(
      --data-binary "@file"
      )。
  4. 支持复合查询:例如文档搜索使用
    AttackComponent CalcCritical
    ,资源搜索使用
    red slime jump
  5. 切勿猜测:永远不要猜测 API 名称、RUID 或枚举值,务必通过搜索或参考文档确认。