Discord
@hash/conveyor
Simulation
1
0
Public

Conveyors

A Conveyor system is composed of multiple agents, creating a path along which other agents can be moved. The Conveyor Library is part of the Material Handling Libraries. You can find further information about them in the HASH docs.

The Conveyor Library is part of the Material Handling Libraries. You can find further information about them in the HASH docs.


A Conveyor system is composed of multiple agents, creating a path along which other agents with the appropriate behavior can be moved.

Defining a Conveyor

To define a conveyor you'll have to include certain behaviors and parameters on your agent.

Behaviors

A Conveyor system operates by pairing a behavior on the Conveyor agents with another behavior on the agent moving along the path.

Basic conveyors can simply run the @hash/conveyor/convey_basic.js behavior, which simply marks this agent as a conveyor. By using the @hash/coneyor/convey_turntable.js behaviors, you can create branching paths in your conveyor system. This branching logic can either be conditional (checking certain fields on the conveyed agent) or simply engage when the standard path is blocked.

Agents can move across Conveyors by running the @hash/conveyor/move.js behavior. This behavior includes a check that ensures that conveyed agents will not collide with other agents along the conveyer path.

Parameters

Conveyor-related parameters must be defined in state.conveyor_parameters. All Conveyor agents must have a direction parameter which indicates in which direction it will move a conveyed agent.

Agents running @hash/conveyor/convey_turntable.js have two possible sets of parameters. If you want to define a conditional turntable, it must include a contitions struct which defines the possible strings conveyed agents might have on their condition_field, and key them to the direction they will be conveyed:

{
  "condition_field": string, // The conveyed agent field to match in "conditions" 
  "check_direction": number[3], // This should typically be the direction of the Conveyor which feeds the current one
  "conditions": {
    "<option1>": number[3], // String to match to the "condition_field"
    "<option2>": number[3]  // And direction arrays for that option
  }
}

If you want to define a turntable which redirects agents when a segement of conveyor is too crowded, the you'll need the following parameters instead:

{
  "original_direction": number[3], // The standard convey direction
  "alt_direction": number[3], // The alternate direction
}

Conveyed agents do not need to specify any parameters.

Conveyor Logic

Conveyed agents move by checking the conveyor_parameters.direction field, which is set by the Conveyor agents. They use this to determine which direction they will move in the next step.

Conditional Conveyors need to check the state of incoming agents to see in which direction they should be sent, which is why the check_direction field exists. Checking the agent before it arrives allows the Conveyor to modify its direction field appropriately.