> For the complete documentation index, see [llms.txt](https://docs.jackf.red/cronslab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jackf.red/cronslab/cronslab.md).

# Cronslab

An advanced redstone scheduler block with a similar syntax to [cron](https://en.wikipedia.org/wiki/Cron). See [#usage](#usage "mention") for a heavily detailed overview, or [Examples](/cronslab/examples.md) for a quick start.

### Crafting

<figure><img src="/files/R7egCiRCEyFa2dCpVYpW" alt="Crafting recipe for two Cronslabs: a clock in the center with two copper ingots either side."><figcaption></figcaption></figure>

### Usage

Right click to open the GUI and input the expression. The GUI contains a "to English" translator of the given expression, but this is also gone over below.

#### Fields

A cronslab is made up of four fields representing **ticks**, **seconds**, **minutes**, and **minecraft days**. Each describes which value of that field's interval the signal should be active.

{% hint style="info" %}
There are some extra rules for this different to cron, but have been made in a way that tries to 'make sense' for Minecraft, and doesn't need consideration. See [#quirks](#quirks "mention").
{% endhint %}

Example:

The **tick** field has an interval of **20** (since 20 ticks = 1 second). So for the following values of the field:

```
0:     The 0th tick of every second.
*:     Every tick of every second.
*/4:   The 4th tick.
0-3:   0th to 3rd tick.
0-9/2: Every even tick between 0 and 9.
```

Fields can be a comma-separated list of values, which pass if any value passes (an OR expression):

```
5,6:    The 5th or 6th tick of.
*/2,15: Any even tick, or the 15th tick.
```

#### Expression

An expression is made of the four fields, where all must pass to emit a signal.

```
* 0-29 */2 *:  Constant for the first 30 seconds of the minute AND only every other minute.
0 0-5 * *:     Five 1-tick pulses a second apart every minute.
```

### Quirks

There are two things that are worth noting for advanced use.

#### Gametime vs Daytime

Per the [minecraft wiki](https://minecraft.wiki/w/Commands/time#Usage):

> There are \[multiple] types of time:
>
> * Gametime - The total number of [game ticks](https://minecraft.wiki/w/Game_tick) that have elapsed in the world.
> * Daylight cycle time (aka. internal daytime) - The total number of game ticks that have elapsed during the daylight cycle. It does not elapse when the game rule [`advance_time`](https://minecraft.wiki/w/Game_rule#advance_time) is `false`.

By default, the expression evaluator will operate on **gametime**. This counts from the world start, and isn't affected by the `advance_time` gamerule, but might not be synced to the visual day/night cycle. However, if the **day** field is **relevant** (i.e. not `*`), then the Cronslab will work on the **daytime**. This is synchronised with the visual day/night cycle, but will not update when `advance_time` is false.

#### Interval Extension

In normal cron you can't schedule, for example, every 45 minutes in a single expression. Cronslab gets around this by possibly *extending the interval* of a field when checked. The rules are meant be common sense, but for clarify:

* If the field is **cyclical** (a wildcard or unbounded range e.g. `4/2`), then it's interval is multiplied by each field 'ahead' that has at least one **wildcard** value.
* Example: The ticks field in `*/15 * 0 *` will have it's interval extended to `20 * 60 = 1200`, which correctly spaces signals every 15 ticks.
* The **days** field has an effective infinite interval.
