-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
342 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# AcaruaMC特有数据类型/预定义结构体介绍 | ||
|
||
## Position | ||
|
||
原型 | ||
|
||
``` | ||
Struct Position { | ||
mut x: Int; | ||
mut y: Int; | ||
mut z: Int; | ||
} | ||
``` | ||
|
||
构造和使用Position对象 | ||
|
||
``` | ||
let start Position(x=0,y=0,z=0) | ||
mut end Position(x=5,y=5,z=5) | ||
end.x = 0 | ||
fill(block, start, end) | ||
``` | ||
|
||
> 通过ConstPosition可以引用Position的不可变版本,即属性全部定义为常量 | ||
## VolumeArea | ||
|
||
原型 | ||
|
||
``` | ||
Struct VolumeArea { | ||
mut dx: Int; | ||
mut dy: Int; | ||
mut dz: Int; | ||
} | ||
``` | ||
|
||
> 通过ConstVolumeArea可以引用VolumeArea的不可变版本,即属性全部定义为常量 | ||
## RotateArea | ||
|
||
原型 | ||
|
||
``` | ||
Struct RotateArea { | ||
mut x: Tuple<Int>; | ||
mut y: Tuple<Int>; | ||
} | ||
``` | ||
|
||
> 通过ConstVolumeArea可以引用VolumeArea的不可变版本,即属性全部定义为常量 | ||
## EntitySelectorArea | ||
|
||
原型 | ||
|
||
``` | ||
Enum EntitySelectorArea { | ||
let p "@p"; | ||
let a "@a"; | ||
let r "@r"; | ||
let e "@e"; | ||
let s "@s"; | ||
} | ||
``` | ||
|
||
## Advancements | ||
|
||
原型 | ||
``` | ||
Enum Advancements { | ||
let root "story/root"; | ||
let stone "story/mine_stone"; | ||
let upgrade_tools "story/upgrade_tools"; | ||
let iron "story/smelt_iron"; | ||
let obtain "story/obtain_armor"; | ||
let lava "story/lava_bucket"; | ||
let irontool "story/iron_tools"; | ||
let deflect_arrow "story/deflect_arrow"; | ||
let obsidian "story/form_obsidian"; | ||
let diamond "story/mine_diamond"; | ||
let nether "story/enter_the_nether"; | ||
let shiny_gear "story/shiny_gear"; | ||
let enchante "story/enchant_item"; | ||
let capitalist "story/cure_zombie_villager"; | ||
let endeye "follow_ender_eye"; | ||
let end "enter_the_end"; | ||
``` | ||
|
||
|
||
## EntitySelector | ||
|
||
表示实体选择器 | ||
|
||
原型 | ||
|
||
``` | ||
struct EntitySelector { | ||
let r: Int; | ||
let rm: Int; | ||
let limit: Int; | ||
let nbt: String; | ||
let tags: String; | ||
let team: String; | ||
let name: String; | ||
let type: String; | ||
let gamemode: String; | ||
let predicate: String; | ||
let distence: Tuple<Int>; | ||
let scores: Tuple<Int>; | ||
let level: Tuple<Int>; | ||
let advancements: Map<Advancements, Boolean> | ||
let pos: Position; | ||
let va: VolumeArea; | ||
let rotate: RotateArea; | ||
let area: EntitySelectorArea; | ||
``` | ||
|
||
> 通过MutableEntitySelector可以引用EntitySelector的可变版本,即属性全部定义为变量 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# AcaruaMC.Std标准库介绍 | ||
|
||
## 信息显示 | ||
|
||
### ```Print()```函数 | ||
|
||
对应的命令: ```/tellraw```或```/tell``` | ||
|
||
参数: | ||
|
||
| 键名 | 释义 | 类型 | | ||
|----------|:-------------------------------:|--------:| | ||
| content | 要打印的内容 | String | | ||
| plain | 是否使用```tell```指令而非```tellraw``` | Boolean | | ||
| target | 玩家名 | String | | ||
|
||
|
||
### ```Title()```函数 | ||
|
||
参数: | ||
|
||
| 键名 | 释义 | 类型 | | ||
|----------|:-----------:|--------:| | ||
| content | 要显示的内容 | String | | ||
| sub | 小标题内容 | String | | ||
| action | 在动作栏上方显示的文本 | String | | ||
| clear | 是否清空标题 | Boolean | | ||
| reset | 是否清空副标题 | Boolean | | ||
| fade_in | 淡入时间(s) | Int | | ||
| fade_out | 淡出时间(s) | Int | | ||
| target | 玩家名 | String | | ||
|
||
### ```Msg()```函数 | ||
|
||
对应的命令: ```/msg``` | ||
|
||
参数: | ||
|
||
| 键名 | 释义 | 类型 | | ||
|---------|:-------:|--------:| | ||
| content | 要显示的内容 | String | | ||
| target | 要私信的玩家名 | String | | ||
|
||
### ```Me()```函数 | ||
|
||
对应的命令: ```/me``` | ||
|
||
参数: | ||
|
||
| 键名 | 释义 | 类型 | | ||
|---------|:-------:|--------:| | ||
| content | 要显示的内容 | String | | ||
|
||
### ```Say()```函数 | ||
|
||
对应的命令: ```/say``` | ||
|
||
参数: | ||
|
||
| 键名 | 释义 | 类型 | | ||
|---------|:-------:|--------:| | ||
| content | 要显示的内容 | String | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# 开始使用Acarua | ||
|
||
## 变量和常量的定义 | ||
使用 ```mut``` 关键字定义变量,使用 ```let``` 关键字定义常量.变量和常量的定义方式和类型注解的规则如下: | ||
``` | ||
mut mutiableName: DataType = value; | ||
let constantName: DataType = value; | ||
``` | ||
示例: | ||
``` | ||
mut age: Int 25; | ||
let name: String "John"; | ||
mut demo: Float, demo2: Double = 1.14, 5.14 | ||
``` | ||
|
||
## 条件判断 | ||
使用 ```if (表达式) { 语句... } else { 语句... }``` 进行条件判断. | ||
示例: | ||
``` | ||
if (age >= 18) { | ||
println("You are an adult.") | ||
} | ||
else { | ||
println("You are a minor.") | ||
} | ||
``` | ||
|
||
## 循环 | ||
使用 ```when (条件) { 循环体... }``` 进行循环. | ||
示例: | ||
``` | ||
when (i < 10) { | ||
println(i) | ||
i++ | ||
} | ||
``` | ||
或者使用 ```yield index in generate<int>(0,10) {语句...}``` 实现遍历功能,其中 ```{ 语句... }``` 表示循环体. | ||
示例: | ||
``` | ||
yield index in generate<int>(0,10) { | ||
println(index) | ||
} | ||
``` | ||
|
||
## 数据类型 | ||
主要的数据类型有结构体```Struct```、图```Map```、数组```Array```、元组```Tuple```、枚举```Enum```、整数```Int```、单精度浮点数```Float```、双精度浮点数```Double```、布尔型```Boolean```和字符串```String```. | ||
示例: | ||
``` | ||
struct Person { | ||
mut age: Int; | ||
mut name: String; | ||
} | ||
let employee Map<String, String>(); | ||
mut numbers Array<Int>(5); | ||
let numbers Tuple<Int>(5); | ||
Enum Types { | ||
let del "DELETE"; | ||
let new "NEW"; | ||
... | ||
} | ||
``` | ||
除此之外还有下面这些类型:```UnsignedInt```,```UnsignedLongInt```,```UnsignedShortInt```,```LongInt```,```ShortInt```,```LongDouble``` | ||
|
||
## 自定义类型 | ||
自定义类型主要是类```Class```. | ||
示例: | ||
``` | ||
class ClassName { | ||
// class body | ||
} | ||
``` | ||
|
||
## 四则运算 | ||
四则运算符为 ```+```、```-```、```*```、```/```,还有 ```**``` 表示平方,```//``` 表示开平方,```%``` 表示取余. | ||
示例: | ||
``` | ||
mut sum = 1 + 2; | ||
mut difference = 5 - 3; | ||
mut product = 4 * 6; | ||
mut quotient = 12 / 3; | ||
mut remainder = 10 % 3; | ||
mut square = 2 ** 3; | ||
mut squareRoot = 9 // 3; | ||
``` | ||
|
||
## 逻辑运算符 | ||
逻辑运算符有逻辑非```!```、逻辑与```&&```和逻辑或```||```. | ||
示例: | ||
``` | ||
mut isTrue true; | ||
mut isFalse false; | ||
mut notTrue !isTrue; | ||
mut trueAndFalse isTrue && isFalse; | ||
mut trueOrFalse isTrue || isFalse; | ||
``` | ||
|
||
## 位运算符 | ||
位运算符有按位与```&```、按位或```|```、按位非```-```、按位异或```^```、左移```<<```和右移```>>```. | ||
示例: | ||
``` | ||
let a 5; | ||
let b 3; | ||
let bitwiseAnd = a & b; | ||
let bitwiseOr = a | b; | ||
let bitwiseNot = -a; | ||
let bitwiseXor = a ^ b; | ||
let leftShift = a << 2; | ||
let rightShift = a >> 1; | ||
``` | ||
|
||
## 函数定义 | ||
使用 ```fun``` 关键字定义函数,后接函数名,参数定义在小括号中,可选的返回值类型在大括号之前. | ||
示例: | ||
``` | ||
fun functionName(parameter1: DataType, parameter2: DataType): ReturnType { | ||
// function body | ||
return value; | ||
} | ||
fun printName(name: String) { | ||
println("Name: $name") | ||
} | ||
``` | ||
|
||
## 类定义 | ||
使用 ```class``` 关键字定义类,后接类名,继承关系在类名后的小括号中指定,构造函数名为```类名```,析构函数名为```~类名```. | ||
示例: | ||
``` | ||
class ClassName { | ||
// class body | ||
ClassName() { | ||
// constructor body | ||
} | ||
~ClassName() { | ||
// destructor body | ||
} | ||
} | ||
class Children(Parent) { ... } | ||
``` |