# 函数

## 定义

我们可以在plugins/Craftorithm/function.yml中将多个动作打包为一个组，称之为函数。

## 格式

```yaml
函数名:
  - '语句1'
  - '语句2'
  ...
```

在此处定义的函数体，会被视为语句进行解析，可以被当作语句使用。

### 示例

function.yml

```yaml
example:
  - 'if level > 100'
  - |-
    take-level 10
    return
  - 'take-level 1'
test:
  - return all perm craftorithm.perm.example && level >= 100 && papi %player_name% == YufiriaMazenta
```

recipes/example\_shaped.yml

```
type: 'shaped'
result: 'items:example_item:example_item'
multiple: true
shape:
  - - 'aaa'
    - 'bbb'
    - 'ccc'
  - - 'dd'
    - 'ee'
source:
  a: 'bedrock'
  b: 'command_block'
  c: 'items:example_item:example_item'
  d: 'diamond'
  e: 'iron_ingot'
unlock: true

condition: 'test'
actions:
  - 'example'
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yufiriamazenta.gitbook.io/craftorithm-wiki/script/enchance/function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
