mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-28 05:21:05 +01:00
Change document formatting, finally move cactus cart dropping to node definition for mcl_core:cactus
This commit is contained in:
parent
49ef40aa3c
commit
c56d98ab2f
3 changed files with 28 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
||||||
== Cart-Node interactions
|
## Cart-Node interactions
|
||||||
|
|
||||||
As the cart moves thru the environment, it can interact with the surrounding blocks
|
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
|
thru a number of handlers in the block definitions. All these handlers are defined
|
||||||
|
@ -7,18 +7,18 @@ as:
|
||||||
`function(node_position, cart_luaentity, cart_direction, cart_position)`
|
`function(node_position, cart_luaentity, cart_direction, cart_position)`
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
`node_position` - position of the node the cart is interacting with
|
- `node_position` - position of the node the cart is interacting with
|
||||||
`cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
- `cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
||||||
be nil for minecarts moving thru unloaded blocks
|
be nil for minecarts moving thru unloaded blocks
|
||||||
`cart_direction` - The direction the cart is moving
|
- `cart_direction` - The direction the cart is moving
|
||||||
`cart_position` - The location of the cart
|
- `cart_position` - The location of the cart
|
||||||
`cart_data` - Information about the cart. This will always be defined.
|
- `cart_data` - Information about the cart. This will always be defined.
|
||||||
|
|
||||||
There are several variants of this handler:
|
There are several variants of this handler:
|
||||||
`_mcl_minecarts_on_enter` - The cart enters this block
|
- `_mcl_minecarts_on_enter` - The cart enters this block
|
||||||
`_mcl_minecarts_on_enter_below` - The cart enters above 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_above` - The cart enters below this block
|
||||||
`_mcl_minecarts_on_enter_side` - The cart enters beside this block
|
- `_mcl_minecarts_on_enter_side` - The cart enters beside this block
|
||||||
|
|
||||||
Mods can also define global handlers that are called for every node. These
|
Mods can also define global handlers that are called for every node. These
|
||||||
handlers are defined as:
|
handlers are defined as:
|
||||||
|
@ -26,13 +26,13 @@ handlers are defined as:
|
||||||
`function(node_position, cart_luaentity, cart_direction, node_definition, cart_data)`
|
`function(node_position, cart_luaentity, cart_direction, node_definition, cart_data)`
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
`node_position` - position of the node the cart is interacting with
|
- `node_position` - position of the node the cart is interacting with
|
||||||
`cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
- `cart_luaentity` - The luaentity of the cart that is entering this block. Will
|
||||||
be nil for minecarts moving thru unloaded blocks
|
be nil for minecarts moving thru unloaded blocks
|
||||||
`cart_direction` - The direction the cart is moving
|
- `cart_direction` - The direction the cart is moving
|
||||||
`cart_position` - The location of the cart
|
- `cart_position` - The location of the cart
|
||||||
`cart_data` - Information about the cart. This will always be defined.
|
- `cart_data` - Information about the cart. This will always be defined.
|
||||||
`node_definition` - The definition of the node at `node_position`
|
- `node_definition` - The definition of the node at `node_position`
|
||||||
|
|
||||||
The available hooks are:
|
The available hooks are:
|
||||||
`_mcl_minecarts.on_enter` - The cart enters this block
|
`_mcl_minecarts.on_enter` - The cart enters this block
|
||||||
|
|
|
@ -249,7 +249,7 @@ function DEFAULT_CART_DEF:on_step(dtime)
|
||||||
mod.update_cart_orientation(self)
|
mod.update_cart_orientation(self)
|
||||||
|
|
||||||
end
|
end
|
||||||
local function kill_cart(staticdata)
|
function mod.kill_cart(staticdata)
|
||||||
local pos
|
local pos
|
||||||
minetest.log("action", "cart #"..staticdata.uuid.." was killed")
|
minetest.log("action", "cart #"..staticdata.uuid.." was killed")
|
||||||
|
|
||||||
|
@ -272,6 +272,9 @@ local function kill_cart(staticdata)
|
||||||
local mob = le._passenger.object
|
local mob = le._passenger.object
|
||||||
mob:set_detach()
|
mob:set_detach()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove the entity
|
||||||
|
le.object:remove()
|
||||||
else
|
else
|
||||||
pos = mod.get_cart_position(staticdata)
|
pos = mod.get_cart_position(staticdata)
|
||||||
end
|
end
|
||||||
|
@ -292,8 +295,9 @@ local function kill_cart(staticdata)
|
||||||
|
|
||||||
-- Remove data
|
-- Remove data
|
||||||
destroy_cart_data(staticdata.uuid)
|
destroy_cart_data(staticdata.uuid)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
local kill_cart = mod.kill_cart
|
||||||
|
|
||||||
function DEFAULT_CART_DEF:on_death(killer)
|
function DEFAULT_CART_DEF:on_death(killer)
|
||||||
kill_cart(self._staticdata)
|
kill_cart(self._staticdata)
|
||||||
end
|
end
|
||||||
|
@ -561,26 +565,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
--- Non-entity code
|
--- Non-entity code
|
||||||
if staticdata.connected_at then
|
if staticdata.connected_at then
|
||||||
do_movement(staticdata, dtime)
|
do_movement(staticdata, dtime)
|
||||||
|
|
||||||
-- TODO: move this into mcl_core:cactus _mcl_minecarts_on_enter_side
|
|
||||||
-- Drop minecart if it collides with a cactus node
|
|
||||||
local pos = mod.get_cart_position(staticdata)
|
|
||||||
if pos then
|
|
||||||
local r = 0.6
|
|
||||||
for _, node_pos in pairs({{r, 0}, {0, r}, {-r, 0}, {0, -r}}) do
|
|
||||||
if minetest.get_node(vector.offset(pos, node_pos[1], 0, node_pos[2])).name == "mcl_core:cactus" then
|
|
||||||
kill_cart(staticdata)
|
|
||||||
local le = mcl_util.get_luaentity_from_uuid(staticdata.uuid)
|
|
||||||
if le then
|
|
||||||
le:on_death()
|
|
||||||
le.object:remove()
|
|
||||||
else
|
|
||||||
kill_cart(staticdata)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -48,6 +48,11 @@ minetest.register_node("mcl_core:cactus", {
|
||||||
end),
|
end),
|
||||||
_mcl_blast_resistance = 0.4,
|
_mcl_blast_resistance = 0.4,
|
||||||
_mcl_hardness = 0.4,
|
_mcl_hardness = 0.4,
|
||||||
|
_mcl_minecarts_on_enter_side = function(pos, _, _, _, cart_data)
|
||||||
|
if mcl_minecarts then
|
||||||
|
mcl_minecarts.kill_cart(cart_data)
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mcl_core:reeds", {
|
minetest.register_node("mcl_core:reeds", {
|
||||||
|
|
Loading…
Reference in a new issue