早期测试版!
本模组添加了自动化火箭,可用于在行星之间运输货物。你可以使用 CC:Tweaked 计算机配合以下 API 来控制火箭:
火箭发射台 Lua API
此 API 允许你通过 CC:Tweaked 计算机控制火箭发射台。它提供了启动火箭、管理物品栏以及检查能量等级的功能。
连接
你必须将计算机连接到发射台的中央方块才能访问以下方法。
连接到外部方块则允许你访问通用的物品栏操作方法。
? 物品栏索引
- Lua 中的所有物品栏索引从 1 开始,这与 CC:Tweaked 的惯例一致。
? launch(planet)
尝试向指定的星球发射火箭。(参见 getValidDestinations)
参数
planet (string): 目标星球的名称。
错误
"No rocket found" – 发射台上没有火箭。
"<planet> is not a valid planet" – 指定的星球名称无效。
"Not enough energy to launch" – 发射台能量不足。
"<planet> is too high of a tier for this rocket" – 火箭等级不足以到达该目的地。
? moveItemsFromRocketToLaunchPad(rocketSlot, launchPadSlot)
将物品从火箭的物品栏移动到发射台的物品栏。
参数
rocketSlot (int): 火箭物品栏中的槽位。
launchPadSlot (int): 发射台物品栏中的槽位。
错误
"No rocket found"
"Destination full"
"Invalid slot"
? moveItemsFromLaunchPadToRocket(launchPadSlot, rocketSlot)
将物品从发射台的物品栏移动到火箭的物品栏。
参数
launchPadSlot (int): 发射台物品栏中的槽位。
rocketSlot (int): 火箭物品栏中的槽位。
错误
"No rocket found"
"Destination full"
"Invalid slot"
⚡ getEnergyRequiredForLaunch()
返回发射火箭所需的能量量。
返回值
? getEnergy()
返回发射台当前存储的能量。
返回值
? getMaxEnergy()
返回发射台的最大能量容量。
返回值
? getValidDestinations()
返回有效目标星球名称的表格,键为星球名称,值为到达该星球所需的火箭等级。
返回值
table<string, int>: 包含星球名称(键)和所需火箭等级(值)的表格。
? listLaunchPadInventory()
返回发射台当前的非空物品栏。
返回值
table<int, table>: 一个将槽位索引映射到物品表格的表格,其中包含:
name (string): 显示名称。
id (string): 注册 ID。
count (int): 堆叠数量。
max_count (int): 最大堆叠数量。
? listLaunchPadInputSlotIndexes()
列出被视为输入槽位的槽位索引。
这些是漏斗和其他物品传输模组可以插入物品的槽位。
返回值
? listLaunchPadOutputSlotIndexes()
列出被视为输出槽位的槽位索引。
这些是漏斗和其他物品传输模组可以提取物品的槽位。
返回值
? isRocketPresent()
检查发射台上是否有火箭。
返回值
boolean: 如果存在火箭则返回 true,否则返回 false。
? listRocketInventory()
返回火箭当前的非空物品栏。
返回值
table<int, table>|nil: 如果存在火箭,则返回将槽位索引映射到物品数据的表格;如果未找到火箭,则返回 nil。物品表格包含:
name (string): 显示名称。
id (string): 注册 ID。
count (int): 堆叠数量。
max_count (int): 最大堆叠数量。
EARLY APLPHA!
This mod adds automated rockets you can use to carry cargo between planets. CC:Tweaked computers are used to control the rockets using the API below:
Rocket Launchpad Lua API
This API allows you to control a rocket launchpad from a CC:Tweaked computer. It provides functions to launch rockets, manage inventories, and check energy levels.
Connecting
You must connect the computer to the central block of the launch pad to access the below methods.
Connecting to the outer blocks will allow you to access the generic inventory methods.
? Inventory Slot Indexing
- All inventory slot indexes in Lua start at 1, matching CC:Tweaked's conventions.
? launch(planet)
Attempts to launch a rocket to the specified planet. (See getValidDestinations)
Parameters
planet (string): The name of the destination planet.
Errors
"No rocket found" – No rocket is on the launchpad.
"<planet> is not a valid planet" – The specified planet name is invalid.
"Not enough energy to launch" – The launchpad lacks sufficient energy.
"<planet> is too high of a tier for this rocket" – The rocket tier is too low for the destination.
? moveItemsFromRocketToLaunchPad(rocketSlot, launchPadSlot)
Moves an item from the rocket's inventory to the launchpad's inventory.
Parameters
rocketSlot (int): Slot in the rocket's inventory.
launchPadSlot (int): Slot in the launchpad's inventory.
Errors
"No rocket found"
"Destination full"
"Invalid slot"
? moveItemsFromLaunchPadToRocket(launchPadSlot, rocketSlot)
Moves an item from the launchpad's inventory to the rocket's inventory.
Parameters
launchPadSlot (int): Slot in the launchpad's inventory.
rocketSlot (int): Slot in the rocket's inventory.
Errors
"No rocket found"
"Destination full"
"Invalid slot"
⚡ getEnergyRequiredForLaunch()
Returns the amount of energy required to launch the rocket.
Returns
? getEnergy()
Returns the current stored energy in the launchpad.
Returns
? getMaxEnergy()
Returns the maximum energy capacity of the launchpad.
Returns
? getValidDestinations()
Returns a table of valid destination planet names, with the key being the planet and the value being the required rocket tier to reach it.
Returns
table<string, int>: Table with the key being the planet and the value being the required rocket tier to reach it.
? listLaunchPadInventory()
Returns the current non-empty inventory of the launchpad.
Returns
table<int, table>: A table mapping slot indexes to item tables with:
name (string): Display name.
id (string): Registry ID.
count (int): Stack size.
max_count (int): Maximum stack size.
? listLaunchPadInputSlotIndexes()
Lists which slot indexes are considered input slots.
These are the slots hoppers and other item transportation mods can insert into.
Returns
int[]: List of input slot indexes (1-based).
? listLaunchPadOutputSlotIndexes()
Lists which slot indexes are considered output slots.
These are the slots hoppers and other item transportation mods can extract from.
Returns
int[]: List of output slot indexes (1-based).
? isRocketPresent()
Checks whether a rocket is present on the launchpad.
Returns
boolean: true if a rocket is present, false otherwise.
? listRocketInventory()
Returns the current non-empty inventory of the rocket.
Returns
table<int, table>|nil: Table mapping slot indexes to item data if rocket is present, or nil if no rocket is found. Item tables contain:
name (string): Display name.
id (string): Registry ID.
count (int): Stack size.
max_count (int): Maximum stack size.
评论 0
登录后参与评分
还没有评论,来抢沙发吧