mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-08-22 09:57:25 +02:00
Make sure carts that collide move in the same direction the colliding cart was
This commit is contained in:
parent
bacc8bdf64
commit
3ca5bd0dff
@ -116,7 +116,10 @@ local function handle_cart_leave(self, pos, next_dir)
|
|||||||
handle_cart_enter_exit(self, pos, next_dir, "on_leave" )
|
handle_cart_enter_exit(self, pos, next_dir, "on_leave" )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_cart_collision(cart1, pos, next_dir)
|
local function handle_cart_collision(cart1, prev_pos, next_dir)
|
||||||
|
-- Look ahead one block
|
||||||
|
local pos = vector.add(prev_pos, next_dir)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local carts = minetest.deserialize(meta:get_string("_mcl_minecarts_carts")) or {}
|
local carts = minetest.deserialize(meta:get_string("_mcl_minecarts_carts")) or {}
|
||||||
local cart_uuid = nil
|
local cart_uuid = nil
|
||||||
@ -159,6 +162,9 @@ local function handle_cart_collision(cart1, pos, next_dir)
|
|||||||
|
|
||||||
cart1_staticdata.velocity = v1
|
cart1_staticdata.velocity = v1
|
||||||
cart2_staticdata.velocity = v2
|
cart2_staticdata.velocity = v2
|
||||||
|
|
||||||
|
-- Force the other cart to move the same direction this one was
|
||||||
|
cart2_staticdata.dir = cart1_staticdata.dir
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_cart_node_watches(self, dtime)
|
local function handle_cart_node_watches(self, dtime)
|
||||||
|
Loading…
Reference in New Issue
Block a user