mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
3ad4195dd6
commit a162e18c9c4d91c4020e86cf718d59d3a33b2817 Merge:374848f97
beb61708a
Author: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri May 12 13:40:58 2023 +0200 Merge branch 'mc1.18/dev' into mc1.18/computercraft commit374848f978
Author: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri May 12 13:22:29 2023 +0200 Compilation dependency toggle commitb2cd60b619
Merge:8e1e4e8bd
ee3a079ba
Author: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed May 10 14:37:32 2023 +0200 Merge pull request #4650 from ChristianLW/mc1.18/computercraft Small tweaks to the wiki pages for ComputerCraft integration commitee3a079bac
Author: Christian L.W <bebeu@bebeu.dk> Date: Thu Apr 13 00:55:20 2023 +0200 Small tweaks to the wiki pages commit8e1e4e8bd3
Author: caelwarner <caelawarner@gmail.com> Date: Mon Mar 13 18:31:56 2023 -0700 Added computer to display source ponder tag - Added advanced computer to display source ponder tag - Added missing lang entry for computer display source commit952941e5fc
Author: caelwarner <caelawarner@gmail.com> Date: Mon Mar 13 16:31:16 2023 -0700 Added documentation for train station peripherals and train schedules - Added in depth documentation for working with train stations and train schedules in Lua - Fixed small formatting issues in Lua-Rotation-Speed-Controller.md and Lua-Sequenced-Gearshift.md commit7f3ca1cfa0
Author: caelwarner <caelawarner@gmail.com> Date: Mon Mar 13 16:29:05 2023 -0700 Added isTrainEnroute to station peripheral API - isTrainEnroute checks if a train is currently navigating to the station - Reworded null station exception to "station is not connected to a track" - Refactored StationPeripheral#inAssemblyMode to StationPeripheral#isInAssemblyMode - Added a check to StationPeripheral#disassemble to make sure the station isn't in assembly mode commitfac1ebcd3f
Author: caelwarner <caelawarner@gmail.com> Date: Sat Mar 11 16:12:58 2023 -0800 Added documentation for most peripherals - Lua documentation has been added for all peripherals except the train station (not looking forward to writing that one) - This documentation will be added to the GitHub wiki pages commit3e21996984
Author: caelwarner <caelawarner@gmail.com> Date: Sat Mar 11 15:54:36 2023 -0800 Updated DisplayLinkPeripheral#write to move cursor to the end of the text - This change was made to be more inline with ComputerCraft's builtin display API commit7141c10025
Author: caelwarner <caelawarner@gmail.com> Date: Sat Mar 11 11:45:43 2023 -0800 Added isTrainImminent and hasSchedule to train station API - Added isTrainImminent to check if a train is incoming to the station and hasSchedule to check if the currently present train has a schedule - Added StationPeripheral#getTrainOrThrow to consolidate repetitive null checks commit909484ed5b
Author: caelwarner <caelawarner@gmail.com> Date: Sat Mar 11 11:15:58 2023 -0800 Added getSchedule to train station lua API - Added getSchedule which serializes the currently present train's schedule into a lua table - Refactored StationPeripheral#setSchedule to use a more generic method of serializing NBT tags to lua tables - Moved schedule entry special data from root tag to "Data" - Added StringHelper#camelCaseToSnakeCase - Added variety of put methods to CreateLuaTable commit31ad3aa671
Author: caelwarner <caelawarner@gmail.com> Date: Wed Mar 8 18:22:23 2023 -0800 Extended train station peripheral API - Train station peripherals can now assemble and disassemble trains, check if the station is in assembly mode, set the assembly mode of the station, get and change the station name, check if a train is present at the station and get and change the currently present train name. - Refactored StationEditPacket. Moved most of the logic that was previously in StationEditPacket to StationTileEntity. This allows us to call this logic without having to send a packet. - Made Train#owner nullable. This is needed so that computers can assemble trains. All Train#owner is currently used for is to display the train status to the correct play. commit574cd93a89
Author: caelwarner <caelawarner@gmail.com> Date: Wed Nov 30 00:37:47 2022 -0800 Serialize hasAttachedComputer in ComputerBehaviour - This eliminates some edge cases were peripherals don't realize they're being controlled by a computer on a world save and load commit94e3ed44ad
Author: caelwarner <caelawarner@gmail.com> Date: Wed Oct 26 16:57:12 2022 -0700 Added ComputerScreen - ComputerScreen shows that tile entity currently has computers attached and therefore cannot be controlled manually commit9afdcaded7
Author: caelwarner <caelawarner@gmail.com> Date: Thu Oct 20 10:18:37 2022 -0700 Refactored PeripheralBase to SyncedPeripheral commit7d47fdcd06
Author: caelwarner <caelawarner@gmail.com> Date: Wed Oct 19 22:45:47 2022 -0700 Made LuaFunction's final commit56a1210fff
Author: caelwarner <caelawarner@gmail.com> Date: Wed Oct 19 22:39:38 2022 -0700 Created ComputerBehaviour behaviour - ComputerBehaviour replaces ComputerControllable and SyncedComputerControllable commit19d283b923
Author: caelwarner <caelawarner@gmail.com> Date: Wed Oct 19 16:05:48 2022 -0700 Moved all peripheral classes to computercraft.peripherals package commitab18034b98
Author: caelwarner <caelawarner@gmail.com> Date: Wed Oct 19 15:58:56 2022 -0700 Added Train Station as peripheral - Train station can set a new auto-schedule for the train currently at the station - Added CreateLuaTable to add helper functions for working with lua tables - Added StringHelper util class to convert snake case to camel case commit1091f3227c
Author: caelwarner <caelawarner@gmail.com> Date: Thu Oct 6 21:11:24 2022 -0700 Changed Display Link Peripheral API - Changed the Display Link Peripheral API to be more in line with the Monitor API - Added write, setCursorPos, getCursorPos, getSize, isColor, isColour, clearLine - Removed void writeLine, setLine, writeLines, setLines commit18bfb216b1
Author: caelwarner <caelawarner@gmail.com> Date: Thu Oct 6 02:50:41 2022 -0700 Changed method of checking if a computer attached - After talking with SquidDev from CC: Tweaked I've changed to monitoring IPeripheral#attach and IPeripheral#detach for changes in the number of computers connected to the network, then updating the client using AttachedComputerPacket - This works with wired full modems, wired cabled modems and directly connected computers - Added SyncedPeripheralBase and SyncedComputerControllable for TE's and peripherals that want to be aware of attached computers commit96dc4db6dc
Author: caelwarner <caelawarner@gmail.com> Date: Tue Oct 4 21:11:38 2022 -0700 Sequenced Gearshift screen "greys out" when being controlled by a computer - This is to stop players from trying to using both the builtin sequencing and a computer to control the Sequenced Gearshift at the same time, leading to undefined behaviour - The "greyed out" screen should have a message added explaining why it's greyed out. - Added ComputerControllable#isComputerControlled to check if a tile entity is connected to a modem commit9a80781401
Author: caelwarner <caelawarner@gmail.com> Date: Tue Oct 4 19:36:08 2022 -0700 Added PeripheralBase commitd404f07319
Author: caelwarner <caelawarner@gmail.com> Date: Mon Oct 3 20:46:16 2022 -0700 Added invalidateCaps - Changed setRemoved to invalidateCaps. I don't know why I wasn't just using invalidateCaps from the beginning commit654476d9f3
Author: caelwarner <caelawarner@gmail.com> Date: Mon Oct 3 20:05:25 2022 -0700 Added Rotation Speed Controller and Sequenced Gearshift as peripherals - Rotation Speed Controller can get and set targetSpeed - Sequenced Gearshift can rotate by a certain angle and move a certain distance commit1420406ab7
Author: caelwarner <caelawarner@gmail.com> Date: Mon Oct 3 16:38:12 2022 -0700 Added Speedometer and Stressometer as peripherals - Speedometer can get current speed - Stressometer can get current stress level as well as network stress capacity - Made GaugeTileEntity abstract commit47b8619d07
Author: caelwarner <caelawarner@gmail.com> Date: Mon Oct 3 16:17:05 2022 -0700 Refactored peripheralHandler to peripheral - peripheralHandler was the wrong name. It's just a peripheral. - Changed peripheral type from "cdl" to "Create_DisplayLink" - Added equals function to DisplayLinkPeripheral commit6591c2d46e
Author: caelwarner <caelawarner@gmail.com> Date: Mon Oct 3 14:29:04 2022 -0700 ComputerCraft integration for Display Links - CC computers can now control display links through a variety of functions - Added ComputerControllable interface to define a tile entity as controllable by CC computers - Added CC: Tweaked soft dependency
195 lines
7.9 KiB
Markdown
195 lines
7.9 KiB
Markdown
Train schedules are represented by a table in Lua. The table contains a list of entries where each entry has a single instruction and multiple conditions.
|
|
Each instruction and condition has a `data` table that stores specific data about the instruction or condition.
|
|
|
|
```lua
|
|
schedule = {
|
|
cyclic = true, -- Does the schedule repeat itself after the end has been reached?
|
|
entries = { -- List of entries, each entry contains a single instruction and multiple conditions.
|
|
{
|
|
instruction = {
|
|
id = "create:destination", -- The different instructions are described below.
|
|
data = { -- Data that is stored about the instruction. Different for each instruction type.
|
|
text = "Station 1",
|
|
},
|
|
},
|
|
conditions = { -- List of lists of conditions. The outer list is the "OR" list
|
|
{ -- and the inner lists are "AND" lists.
|
|
{
|
|
id = "create:delay", -- The different conditions are described below.
|
|
data = { -- Data that is stored about the condition. Different for each condition type.
|
|
value = 5,
|
|
time_unit = 1,
|
|
},
|
|
},
|
|
{
|
|
id = "create:powered",
|
|
data = {},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
id = "create:time_of_day",
|
|
data = {
|
|
rotation = 0,
|
|
hour = 14,
|
|
minute = 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
```
|
|
---
|
|
## Instructions
|
|
| ID | Description |
|
|
|----------------------------------------------|---------------------------------|
|
|
| [`"create:destination"`](#createdestination) | Move to a certain train station |
|
|
| [`"create:rename"`](#createrename) | Change the schedule title |
|
|
| [`"create:throttle"`](#createthrottle) | Change the train's throttle |
|
|
|
|
---
|
|
### `"create:destination"`
|
|
Moves the train to the chosen train station. This instruction must have at least one condition.
|
|
|
|
**Data**
|
|
- _text:_ `string` The name of the station to travel to. Can include * as a wildcard.
|
|
|
|
---
|
|
### `"create:rename"`
|
|
Renames the schedule. This name shows up on display link targets. This instruction cannot have conditions.
|
|
|
|
**Data**
|
|
- _text:_ `string` The name to rename the schedule to.
|
|
|
|
---
|
|
### `"create:throttle"`
|
|
Changes the throttle of the train. This instruction cannot have conditions.
|
|
|
|
**Data**
|
|
- _value:_ `number` The throttle to set the train to. Must be an integer within the range of [5..100].
|
|
|
|
---
|
|
## Conditions
|
|
Conditions are stored in a list of lists of conditions. The inner lists contain conditions that get `AND`'ed together. They must all be met for that group to be true.
|
|
The outer list contains the `AND`'ed groups of conditions that get `OR`'ed together. Only one of the groups needs to be true for the schedule to move onto the next instruction.
|
|
|
|
| ID | Description |
|
|
|-----------------------------------------------------|-----------------------------------------------------|
|
|
| [`"create:delay"`](#createdelay) | Wait for a certain delay |
|
|
| [`"create:time_of_day"`](#createtimeofday) | Wait for a specific time of day |
|
|
| [`"create:fluid_threshold"`](#createfluidthreshold) | Wait for a certain amount of fluid to be on board |
|
|
| [`"create:item_threshold"`](#createitemthreshold) | Wait for a certain amount of items to be on board |
|
|
| [`"create:redstone_link"`](#createredstonelink) | Wait for a redstone link to be powered |
|
|
| [`"create:player_count"`](#createplayercount) | Wait for a certain amount of players to be on board |
|
|
| [`"create:idle"`](#createidle) | Wait for cargo loading inactivity |
|
|
| [`"create:unloaded"`](#createunloaded) | Wait for the current chunk to be unloaded |
|
|
| [`"create:powered"`](#createpowered) | Wait for the station to be powered |
|
|
|
|
---
|
|
### `"create:delay"`
|
|
Wait for a set delay. Can be measured in ticks, seconds or minutes.
|
|
|
|
**Data**
|
|
- _value:_ `number` The amount of time to wait for.
|
|
- _time_unit:_ `number` The unit of time. 0 for ticks, 1 for seconds and 2 for minutes.
|
|
|
|
---
|
|
### `"create:time_of_day"`
|
|
Wait for a time of day, then repeat at a specified interval.
|
|
|
|
**Data**
|
|
- _hour:_ `number` The hour of the day to wait for in a 24-hour format. Must be an integer within the range of [0..23].
|
|
- _minute:_ `number` The minute of the hour to wait for. Must be an integer within the range of [0..59].
|
|
- _rotation:_ `number` The interval to repeat at after the time of day has been met. Check the rotation table below for valid values. Must be an integer within the range of [0..9].
|
|
|
|
**Rotation**
|
|
|
|
| Rotation | Time Interval |
|
|
|----------|------------------|
|
|
| 0 | Every Day |
|
|
| 1 | Every 12 Hours |
|
|
| 2 | Every 6 Hours |
|
|
| 3 | Every 4 Hours |
|
|
| 4 | Every 3 Hours |
|
|
| 5 | Every 2 Hours |
|
|
| 6 | Every Hour |
|
|
| 7 | Every 45 Minutes |
|
|
| 8 | Every 30 Minutes |
|
|
| 9 | Every 15 Minutes |
|
|
|
|
---
|
|
### `"create:fluid_threshold"`
|
|
Wait for a certain amount of a specific fluid to be loaded onto the train.
|
|
|
|
**Data**
|
|
- _bucket:_ `table` The bucket item of the fluid.
|
|
- _threshold:_ `number` The threshold in number of buckets of fluid. Must be a positive integer.
|
|
- _operator:_ `number` Whether the condition should wait for the train to be loaded above the threshold, below the threshold or exactly at the threshold. 0 for greater than, 1 for less than, 2 for equal to.
|
|
- _measure:_ `number` The unit to measure the fluid in. This condition supports buckets as the only unit. Set to 0.
|
|
|
|
**See also**
|
|
- [Items](#items) How items are represented in Lua.
|
|
|
|
---
|
|
### `"create:item_threshold"`
|
|
Wait for a certain amount of a specific item to be loaded onto the train.
|
|
|
|
**Data**
|
|
- _item:_ `table` The item.
|
|
- _threshold:_ `number` The threshold of items. Must be a positive integer.
|
|
- _operator:_ `number` Whether the condition should wait for the train to be loaded above the threshold, below the threshold or exactly at the threshold. 0 for greater than, 1 for less than, 2 for equal to.
|
|
- _measure:_ `number` The unit to measure the items in. 0 for items. 1 for stacks of items.
|
|
|
|
**See also**
|
|
- [Items](#items) How items are represented in Lua.
|
|
|
|
---
|
|
### `"create:redstone_link"`
|
|
Wait for a redstone link to be powered.
|
|
|
|
**Data**
|
|
- _frequency:_ `{ table... }` A list of the two items making up the redstone link frequency.
|
|
- _inverted:_ `number` Whether the redstone link should be powered or not to meet the condition. 0 for powered. 1 for not powered.
|
|
|
|
**See also**
|
|
- [Items](#items) How items are represented in Lua.
|
|
|
|
---
|
|
### `"create:player_count"`
|
|
Wait for a certain amount of players to be seated on the train.
|
|
|
|
**Data**
|
|
- _count:_ `number` The number of players to be seated on the train. Must be a positive integer.
|
|
- _exact:_ `number` Whether the seated player count has to be exact to meet the condition. 0 for the exact amount of players seated, 1 for a greater than or equal amount of seated players.
|
|
|
|
---
|
|
### `"create:idle"`
|
|
Wait for a period of inactivity in loading or unloading the train. Can be measured in ticks, seconds or minutes.
|
|
|
|
**Data**
|
|
- _value:_ `number` The amount of idle time to meet the condition. Must be a positive integer.
|
|
- _time_unit:_ `number` The unit of time. 0 for ticks, 1 for seconds and 2 for minutes.
|
|
|
|
---
|
|
### `"create:unloaded"`
|
|
Wait for the chunk the train is in to be unloaded.
|
|
|
|
---
|
|
### `"create:powered"`
|
|
Wait for the station to be powered with a redstone signal.
|
|
|
|
---
|
|
## Items
|
|
In Lua, items are represented with an ID and a count.
|
|
|
|
```lua
|
|
item = {
|
|
id = "minecraft:stone",
|
|
count = 1,
|
|
}
|
|
```
|
|
|
|
- _id:_ `string` The ID of the item.
|
|
- _count:_ `number` The amount of items in the stack. For the purposes of working with train schedules the count should always be 1. Must be an integer.
|