Add on_construct function for cart entity
parent
74693ac4d5
commit
8d74930654
|
@ -1,5 +1,6 @@
|
|||
default
|
||||
tnt
|
||||
farming
|
||||
carts?
|
||||
treasurer?
|
||||
mobs_monster?
|
||||
|
|
|
@ -23,9 +23,11 @@ tsm_railcorridors.nodes = {
|
|||
|
||||
-- List of cart entities. Carts will be placed randomly of the right-hand or left side of
|
||||
-- the main rail.
|
||||
tsm_railcorridors.carts = {
|
||||
"carts:cart",
|
||||
}
|
||||
tsm_railcorridors.carts = {}
|
||||
|
||||
if minetest.get_modpath("carts") then
|
||||
table.insert(tsm_railcorridors.carts, "carts:cart")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mobs_monster") then
|
||||
tsm_railcorridors.nodes.cobweb = "mobs:cobweb"
|
||||
|
@ -42,6 +44,13 @@ end
|
|||
function tsm_railcorridors.on_construct_spawner(pos)
|
||||
end
|
||||
|
||||
-- This is called after a cart has been placed by the game.
|
||||
-- Use this to properly set up entity metadata and stuff.
|
||||
-- * pos: Position of cart
|
||||
-- * cart: Cart entity
|
||||
function tsm_railcorridors.on_construct_cart(pos, cart)
|
||||
end
|
||||
|
||||
-- Fallback function. Returns a random treasure. This function is called for chests
|
||||
-- only if the Treasurer mod is not found.
|
||||
-- pr: A PseudoRandom object
|
||||
|
|
5
init.lua
5
init.lua
|
@ -563,7 +563,10 @@ local function corridor_func(waypoint, coord, sign, up_or_down, up_or_down_next,
|
|||
if placed then
|
||||
local cart_type = pr:next(1, #tsm_railcorridors.carts)
|
||||
-- FIXME: The cart sometimes fails to spawn
|
||||
minetest.add_entity(cpos, tsm_railcorridors.carts[cart_type])
|
||||
local cart = minetest.add_entity(cpos, tsm_railcorridors.carts[cart_type])
|
||||
if cart then
|
||||
tsm_railcorridors.on_construct_cart(cpos, cart)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue