2024-04-11 00:48:24 +02:00
|
|
|
## Cart-Node interactions
|
2024-04-11 00:22:17 +02:00
|
|
|
|
|
|
|
As the cart moves thru the environment, it can interact with the surrounding blocks
|
|
|
|
thru a number of handlers in the block definitions. All these handlers are defined
|
|
|
|
as:
|
|
|
|
|
|
|
|
`function(node_position, cart_luaentity, cart_direction, cart_position)`
|
|
|
|
|
|
|
|
Arguments:
|
2024-04-11 00:48:24 +02:00
|
|
|
- `node_position` - position of the node the cart is interacting with
|
|
|
|
- `cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
2024-04-11 00:22:17 +02:00
|
|
|
be nil for minecarts moving thru unloaded blocks
|
2024-04-11 00:48:24 +02:00
|
|
|
- `cart_direction` - The direction the cart is moving
|
|
|
|
- `cart_position` - The location of the cart
|
|
|
|
- `cart_data` - Information about the cart. This will always be defined.
|
2024-04-11 00:22:17 +02:00
|
|
|
|
|
|
|
There are several variants of this handler:
|
2024-04-11 00:48:24 +02:00
|
|
|
- `_mcl_minecarts_on_enter` - The cart enters this block
|
|
|
|
- `_mcl_minecarts_on_enter_below` - The cart enters above this block
|
|
|
|
- `_mcl_minecarts_on_enter_above` - The cart enters below this block
|
|
|
|
- `_mcl_minecarts_on_enter_side` - The cart enters beside this block
|
2024-04-11 00:22:17 +02:00
|
|
|
|
|
|
|
Mods can also define global handlers that are called for every node. These
|
|
|
|
handlers are defined as:
|
|
|
|
|
|
|
|
`function(node_position, cart_luaentity, cart_direction, node_definition, cart_data)`
|
|
|
|
|
|
|
|
Arguments:
|
2024-04-11 00:48:24 +02:00
|
|
|
- `node_position` - position of the node the cart is interacting with
|
|
|
|
- `cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
2024-04-11 00:22:17 +02:00
|
|
|
be nil for minecarts moving thru unloaded blocks
|
2024-04-11 00:48:24 +02:00
|
|
|
- `cart_direction` - The direction the cart is moving
|
|
|
|
- `cart_position` - The location of the cart
|
|
|
|
- `cart_data` - Information about the cart. This will always be defined.
|
|
|
|
- `node_definition` - The definition of the node at `node_position`
|
2024-04-11 00:22:17 +02:00
|
|
|
|
|
|
|
The available hooks are:
|
|
|
|
`_mcl_minecarts.on_enter` - The cart enters this block
|
|
|
|
`_mcl_minecarts.on_enter_below` - The cart enters above this block
|
|
|
|
`_mcl_minecarts.on_enter_above` - The cart enters below this block
|
|
|
|
`_mcl_minecarts.on_enter_side` - The cart enters beside this block
|
|
|
|
|
|
|
|
Only a single function can be installed in each of these handlers. Before installing,
|
|
|
|
preserve the existing handler and call it from inside your handler if not `nil`.
|