> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/chang-jing-yun-xing-shi/overview.md).

# 概述

Decentraland 场景运行时是一个沙盒化的执行环境，在其中一个 [场景](https://github.com/decentraland/docs/tree/main/content/entity-types/scenes.md) 运行其主脚本。

每个场景都运行在自己的独立运行时中。在其中，它可以访问某些 [全局对象](https://github.com/decentraland/docs/tree/main/contributor/globals.md) 并且可以从 [模块](https://github.com/decentraland/docs/tree/main/contributor/modules.md) 中导入运行时库。

```mermaid
flowchart TB
    subgraph WorldExplorer["世界探索器"]
        subgraph Runtime1["运行时 1"]
            Scene1["场景"]
        end
        
        subgraph Runtime2["运行时 2"]
            Scene2["场景"]
        end
        
        subgraph Runtime3["运行时 3"]
            Scene3["场景"]
        end
        
        Scene1 --> Library["运行时模块库"]
        Scene2 --> Library
        Scene3 --> Library
    end
```

通过从运行时库导入模块，场景可以访问广泛的功能，包括：

* 创建实体并控制其行为
* 与玩家交互
* 与其他玩家通信
* 检查世界状态
* 连接外部服务
* 进行 web3 支付

在实践中，场景会把 [Decentraland SDK](https://github.com/decentraland/docs/tree/main/contributor/creator/sdk7/getting-started/sdk-101.md) 与其代码一起打包，这封装了运行时库的 RPC 风格接口，并提供了更优雅、更易用的 API。

{% hint style="info" %}
请注意，SDK *并不是* Decentraland 协议的一部分，只有更底层的接口才是。场景可以决定是打包 SDK，还是使用替代库。
{% endhint %}

### 全局对象

在沙盒化环境中， [场景](https://github.com/decentraland/docs/tree/main/content/entity-types/scenes.md) 假定某些对象和函数是全局可用的。其中一些是标准的 ES2020 对象（例如 `Date` 或 `Math`），而其他对象则由运行时注入，用于实现诸如引入模块、记录日志消息和调度回调等功能。

参见 [globals](https://github.com/decentraland/docs/tree/main/contributor/globals.md) 了解更多详情。

### 模块

该 [`require`](https://github.com/decentraland/docs/tree/main/contributor/globals.md#module) 全局函数可以导入由 [运行时库](https://github.com/decentraland/docs/tree/main/contributor/execution.md)提供的模块。这些模块允许有选择地导入诸如 ECS 或 Communications 系统之类的工具。

有关完整列表，请参见运行时模块部分。

### 执行

运行时要求场景实现一组特定的方法，并保证它们会按照某些规则被调用。

查看 [执行](https://github.com/decentraland/docs/tree/main/contributor/execution.md) 了解更多。

### 权限

敏感功能，例如向第三方服务发起 HTTP 请求，会受到运行时的限制，除非由 [场景](https://github.com/decentraland/docs/tree/main/content/entity-types/scenes.md)请求并由玩家授予。

查看 [权限](https://github.com/decentraland/docs/tree/main/contributor/permissions.md) 以了解更多信息。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/contributor/contributor-zh/chang-jing-yun-xing-shi/overview.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
