diff options
author | stujones11 <stujones111@gmail.com> | 2016-01-22 18:54:56 +0000 |
---|---|---|
committer | stujones11 <stujones111@gmail.com> | 2016-01-22 18:54:56 +0000 |
commit | 0e9a29ddfc38ce8c198be21bd9597a7d5f03a9d4 (patch) | |
tree | 14072eb3afb5c17824530cd879c4fe0f78908d66 | |
parent | dc2ca22a8b876eac69947b244d4f6ae274927e59 (diff) |
Set cart pitch and yaw on placement
-rw-r--r-- | railcart/init.lua | 4 | ||||
-rw-r--r-- | railcart/railcart.lua | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/railcart/init.lua b/railcart/init.lua index 7ca7fe2..8d60051 100644 --- a/railcart/init.lua +++ b/railcart/init.lua @@ -165,12 +165,16 @@ minetest.register_craftitem("railcart:cart", { return end end + local cons = railtrack:get_connections(pos) local cart = railcart.cart:new() cart.id = #railcart.allcarts + 1 cart.inv = railcart:create_detached_inventory(cart.id) cart.pos = pos cart.prev = vector.new(pos) cart.accel = railtrack:get_acceleration(pos) + if cons[1] then + cart.target = cons[1] + end table.insert(railcart.allcarts, cart) railcart:save() if not minetest.setting_getbool("creative_mode") then diff --git a/railcart/railcart.lua b/railcart/railcart.lua index 68174b6..655fffe 100644 --- a/railcart/railcart.lua +++ b/railcart/railcart.lua @@ -215,11 +215,12 @@ function railcart:update(cart, time, object) end end local speed = railcart:velocity_to_speed(cart.vel) - if not cart.target then + if cart.target then + cart.dir = railtrack:get_direction(cart.target, cart.pos) + else speed = 0 end if speed > RAILCART_SPEED_MIN then - cart.dir = railtrack:get_direction(cart.target, cart.pos) local d1 = railtrack:get_distance(cart.prev, cart.target) local d2 = railtrack:get_distance(cart.prev, cart.pos) local dist = d1 - d2 |