PowerAE2CC 桥接
PowerAE2CC Bridge 是 AE2CC Bridge 的一个分支,它添加了一个简单的侧边模块方块,可用于从 ComputerCraft 计算机访问 Applied Energistics 2 ME 系统。
注意:目前,该侧边模块仅提供一个相对较小的 API。如果您发现缺少所需的功能,请在我们的问题跟踪器中提交功能请求。
方块
当连接到 Applied system 时,桥接方块将消耗 5 AE/t 的电力以及一个通道。
侧边模块 API(函数)
getAvailableObjects()
返回当前在 ME 系统中可用的对象列表。
返回值
{ { type = string, id = string, displayName = string, amount = number }... } –
包含 ME 系统中可用对象列表的表格
getCraftableObjects()
返回可以由 ME 系统制作的对象列表。
返回值
{ { type = string, id = string, displayName = string }... } – 包含可由 ME 系统制作的对象列表的表格
getCraftingCPUs()
返回 ME 系统中可用的制作 CPU 列表。
返回值
{ cpu... }
其中 cpu 是一个定义如下所示的表格:
| 键 |
类型 |
描述 |
availableCoProcessors |
number |
可用的协处理器数量。 |
availableStorage |
number |
可用的制作存储量。 |
selectionMode |
string |
CPU 的选择模式。(可以是 ANY、MACHINE_ONLY 或 PLAYER_ONLY。) |
jobStatus |
string? |
有关当前正在运行的作业的信息。 |
name |
string? |
CPU 的自定义名称。 |
其中 jobStatus 是一个定义如下所示的表格:
| 键 |
类型 |
描述 |
totalObjects |
number |
作业期间将要制作的对象总数。 |
craftedObjects |
number |
已制作的对象数量。 |
elapsedNanos |
number |
自作业开始以来经过的时间(以纳秒为单位)。 |
systemID |
string? |
ME 系统分配给运行中作业的 ID。 |
output |
output |
作业的产出。 |
其中 output 定义如下所示:
| 键 |
类型 |
描述 |
amount |
number |
请求的对象数量。 |
type |
string |
对象的类型。 |
id |
string |
对象的 ID。 |
displayName |
string |
对象的显示名称。 |
备注
出于技术原因,在某些情况下确定 systemID 可能会失败。如果发生这种情况,则不包含 systemID 并记录错误。如果您使用的是最新版本的 AE2 和 AE2CC Bridge,请确保此问题已在您对应版本的问题跟踪器中被知晓。
getIssuedCraftingJobs
返回由侧边模块发出的未完成的制作作业列表。
返回值
{ { state = string, jobID = string, systemID = string? }... } – 包含由侧边模块发出的每个未完成作业的对象列表的表格。
备注
要使作业包含在输出中,其状态必须为 SCHEDULED 或 STARTED。如果作业已开始运行,则会包含额外的 systemID 字段。此 ID 是 ME 系统分配给运行中作业的 ID(与仅对侧边模块本地有效的 jobID 相对)。
getAllCraftingRequests
返回所有制作 CPU 当前正在处理的所有制作请求列表。
返回值
{ craftingRequest, ...}
其中 craftingRequest 是一个具有以下属性的表格:
| 键 |
类型 |
描述 |
amount |
number |
当前正在制作的物品数量 |
displayName |
string |
正在制作的物品的显示名称(即游戏内的物品名称) |
systemID |
string |
正在制作的物品的 ID(遵循 Minecraft 的 ID 系统) |
示例:
{
{
amount = 1,
displayName = "Oak Planks",
systemID = "minecraft:oak_planks"
}
}
scheduleCrafting(type, id, amount)
调度一个制作作业。
参数
type: string – 要制作的对象的类型("fluid" 或 "item")
id: string – 要制作的对象的 ID
amount: number – 要制作的对象的数量
返回值
string – 代表制作作业的唯一 ID
备注
注意:此方法故意命名为 scheduleCrafting,因为调度制作作业并不会立即启动制作过程。相反,制作作业将在 ME 系统准备好后的某个未来时间点启动。
要与制作作业一起工作,有必要了解它们的生命周期。
flowchart LR
Scheduled --> Started
Started --> Done
Started --> Cancelled
Scheduled --> Cancelled
最初,新建的制造任务的初始状态为 SCHEDULED。在创建过程中,ME 系统被指示为制造任务做好准备(包括计算精确的制造方案)。
一旦系统完成所有必要的准备工作,制造任务的状态将变为 STARTED。可以通过 ae2cc:crafting_started 事件来监听此状态变更。
最后,当制造任务完成后,其状态变为 DONE,并触发 ae2cc:crafting_done 事件。
此外,如果在制造任务的生命周期中任何阶段发生取消或错误,将触发 ae2cc:crafting_cancelled 事件。
外设 API(事件)
ae2cc:crafting_cancelled
当制造任务被取消时,会触发 ae2cc:crafting_cancelled 事件。
返回值
string – 事件名称
string – 被取消的制造任务的 ID
string - 取消原因
备注
取消原因始终为以下之一:
| 值 |
描述 |
CANCELLED |
任务被取消(手动或由机器执行)。 |
CPU_NOT_FOUND |
未找到选定的制造 CPU。 |
INCOMPLETE_PLAN |
无法为该任务计算出制造方案。 |
NO_CPU_FOUND |
未找到可执行该任务的制造 CPU。 |
CPU_BUSY |
选定的制造 CPU 正忙。 |
CPU_OFFLINE |
选定的制造 CPU 处于离线状态。 |
CPU_TO_SMALL |
选定的制造 CPU 容量不足,无法处理该任务。 |
MISSING_INGREDIENT |
无法获取任务所需的某种原料。 |
ae2cc:crafting_done
当制造任务完成时,会触发 ae2cc:crafting_done 事件。
返回值
string – 事件名称
string – 已完成的制造任务的 ID
ae2cc:crafting_started
当先前处于 SCHEDULED 状态的制造任务状态变为 STARTED 时,会触发 ae2cc:crafting_started 事件。
返回值
string – 事件名称
string – 已启动的制造任务的 ID
PowerAE2CC Bridge
PowerAE2CC Bridge is a fork of AE2CC Bridge that adds a simple peripheral block that may be used to access an Applied Energistics 2
ME system from ComputerCraft computers.
Note: Currently, the peripheral only exposes a fairly small API. If you
find that functionality you need is missing, please file a feature request in
our issue tracker.
Block
The bridge block will use when connected to an Applied system 5 AE/t of power as well as consume a channel.
Peripheral API (Functions)
getAvailableObjects()
Returns a list of objects that are currently available in the ME system.
Returns
{ { type = string, id = string, displayName = string, amount = number }... } –
a table with a list of objects available in the ME system
getCraftableObjects()
Returns a list of objects that can be crafted by the ME system.
Returns
{ { type = string, id = string, displayName = string }... } – a table with
a list of objects that can be crafted by the ME system
getCraftingCPUs()
Returns a list of crafting CPUs available in the ME system.
Returns
{ cpu... }
where cpu is a table defined as follows:
| Key |
Type |
Description |
availableCoProcessors |
number |
The number of available co-processors. |
availableStorage |
number |
The amount of available crafting storage. |
selectionMode |
string |
The selection mode of the CPU. (Either ANY, MACHINE_ONLY, or PLAYER_ONLY.) |
jobStatus |
string? |
Information about the currently running job. |
name |
string? |
The custom name of the CPU. |
where jobStatus is a table defined as follows:
| Key |
Type |
Description |
totalObjects |
number |
The total amount of objects that will be crafted during the job. |
craftedObjects |
number |
The amount of crafted objects. |
elapsedNanos |
number |
The time (in nanoseconds) that has elapsed since the job has started. |
systemID |
string? |
The ID given to the running job by the ME system. |
output |
output |
The job's output. |
where output is defined as follows:
| Key |
Type |
Description |
amount |
number |
The number of requested objects. |
type |
string |
The type of the object. |
id |
string |
The ID of the object. |
displayName |
string |
The display name of the object. |
Remarks
For technical reasons, determining the systemID may fail in some cases. If
this happens, the systemID is not included and an error is logged. If you
are using up-to-date versions of AE2 and AE2CC Bridge, please make sure this
issue is known in the issue tracker for your versions.
getIssuedCraftingJobs
Returns a list of unfinished crafting jobs issued by the peripheral.
Returns
{ { state = string, jobID = string, systemID = string? }... } – a table with
a list of objects for each unfinished job issued by the peripheral.
Remarks
For a job to be included in the output, its state must either be SCHEDULED or
STARTED. If the job has started running, an additional systemID is field is
included. This ID is the ID given to the running job by the ME system (opposed
to the jobID which is local to a peripheral).
getAllCraftingRequests
Returns a list of all the currently being processed crafts by all crafting cpus
Returns
{ craftingRequest, ...}
where craftingRequest is a table with the following attributes
| Key |
Type |
Description |
amount |
number |
The amount of the item currently being crafted |
displayName |
string |
The display name of the item being crafted (AKA the in game item name) |
systemID |
string |
The id of the item being crafted (following minecraft's id system) |
Example:
{
{
amount = 1,
displayName = "Oak Planks",
systemID = "minecraft:oak_planks"
}
}
scheduleCrafting(type, id, amount)
Schedules a crafting job.
Parameters
type: string – the type of the object to craft ("fluid" or "item")
id: string – the ID of the object to craft
amount: number – the amount of the object to craft
Returns
string – a unique ID representing the crafting job
Remarks
Note: This method is deliberately named scheduleCrafting as scheduling a
crafting job does not actually start a crafting process immediately. Instead,
the crafting job is started at some point in the future when the ME system is
ready.
To work with crafting jobs, it is necessary to understand their lifecycle.
flowchart LR
Scheduled --> Started
Started --> Done
Started --> Cancelled
Scheduled --> Cancelled
Initially, a newly created crafting job's state is SCHEDULED. During creation,
the ME system is instructed to prepare for the crafting job (which includes
calculating) the exact crafting plan.
Once the system has finished all necessary preparations, the crafting job's
state changes to STARTED. The ae2cc:crafting_started event can be used to
listen to this state change.
Finally, when the crafting job is finished, it's state changes to DONE and the
ae2cc:crafting_done event is fired.
Additionally, if the job is cancelled or an error occurs at any point of the
crafting job's lifecycle, the ae2cc:crafting_cancelled event is fired.
Peripheral API (Events)
ae2cc:crafting_cancelled
The ae2cc:crafting_cancelled event is fired when a crafting job is cancelled.
Return Values
string – the name of the event
string – the ID of the cancelled crafting job
string - the reason for the cancellation
Remarks
The reason for the cancellation is always one of:
| Value |
Description |
CANCELLED |
The job was cancelled (either manually or by a machine). |
CPU_NOT_FOUND |
The selected crafting CPU was not found. |
INCOMPLETE_PLAN |
No crafting plan could be calculated for the job. |
NO_CPU_FOUND |
No crafting CPU to execute the job was found. |
CPU_BUSY |
The selected crafting CPU is busy. |
CPU_OFFLINE |
The selected crafting CPU is offline. |
CPU_TO_SMALL |
The selected crafting CPU is too small to process the job. |
MISSING_INGREDIENT |
Could not obtain one of the ingredients needed for the job. |
ae2cc:crafting_done
The ae2cc:crafting_done event is fired when a crafting job is done.
Return Values
string – the name of the event
string – the ID of the finished crafting job
ae2cc:crafting_started
The ae2cc:crafting_started event is fired when the state of a previously
SCHEDULED crafting job changes to STARTED.
Return Values
string – the name of the event
string – the ID of the started crafting job
评论 0
登录后参与评分
还没有评论,来抢沙发吧