mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 09:31:07 +01:00
Leave minecart by Pressing Sneak, https://git.minetest.land/MineClone2/MineClone2/issues/567
This commit is contained in:
parent
fb5f86d829
commit
44d3f25767
3 changed files with 19 additions and 15 deletions
|
@ -175,6 +175,19 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
cart.on_activate_by_rail = on_activate_by_rail
|
cart.on_activate_by_rail = on_activate_by_rail
|
||||||
|
|
||||||
function cart:on_step(dtime)
|
function cart:on_step(dtime)
|
||||||
|
local ctrl, player = nil, nil
|
||||||
|
if self._driver then
|
||||||
|
player = minetest.get_player_by_name(self._driver)
|
||||||
|
if player then
|
||||||
|
ctrl = player:get_player_control()
|
||||||
|
-- player detach
|
||||||
|
if ctrl.sneak then
|
||||||
|
detach_driver(self)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
local update = {}
|
local update = {}
|
||||||
if self._last_float_check == nil then
|
if self._last_float_check == nil then
|
||||||
|
@ -190,18 +203,14 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
node = minetest.get_node(rou_pos)
|
node = minetest.get_node(rou_pos)
|
||||||
local g = minetest.get_item_group(node.name, "connect_to_raillike")
|
local g = minetest.get_item_group(node.name, "connect_to_raillike")
|
||||||
if g ~= self._railtype and self._railtype ~= nil then
|
if g ~= self._railtype and self._railtype ~= nil then
|
||||||
local player
|
|
||||||
-- Detach driver
|
-- Detach driver
|
||||||
if self._driver then
|
if player then
|
||||||
if self._old_pos then
|
if self._old_pos then
|
||||||
self.object:set_pos(self._old_pos)
|
self.object:set_pos(self._old_pos)
|
||||||
end
|
end
|
||||||
mcl_player.player_attached[self._driver] = nil
|
mcl_player.player_attached[self._driver] = nil
|
||||||
player = minetest.get_player_by_name(self._driver)
|
player:set_detach()
|
||||||
if player then
|
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
||||||
player:set_detach()
|
|
||||||
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Explode if already ignited
|
-- Explode if already ignited
|
||||||
|
@ -337,14 +346,6 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ctrl, player = nil, nil
|
|
||||||
if self._driver then
|
|
||||||
player = minetest.get_player_by_name(self._driver)
|
|
||||||
if player then
|
|
||||||
ctrl = player:get_player_control()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Stop cart if velocity vector flips
|
-- Stop cart if velocity vector flips
|
||||||
if self._old_vel and self._old_vel.y == 0 and
|
if self._old_vel and self._old_vel.y == 0 and
|
||||||
(self._old_vel.x * vel.x < 0 or self._old_vel.z * vel.z < 0) then
|
(self._old_vel.x * vel.x < 0 or self._old_vel.z * vel.z < 0) then
|
||||||
|
@ -643,6 +644,7 @@ register_minecart(
|
||||||
if player then
|
if player then
|
||||||
mcl_player.player_set_animation(player, "sit" , 30)
|
mcl_player.player_set_animation(player, "sit" , 30)
|
||||||
player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0})
|
player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0})
|
||||||
|
mcl_tmp_message.message(clicker, S("Sneak to dismount"))
|
||||||
end
|
end
|
||||||
end, name)
|
end, name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,3 +33,4 @@ Activates minecarts when powered=Активирует особые вагоне
|
||||||
Emits redstone power when a minecart is detected=Испускает энергию редстоуна при обнаружении вагонетки
|
Emits redstone power when a minecart is detected=Испускает энергию редстоуна при обнаружении вагонетки
|
||||||
Vehicle for fast travel on rails=Быстрый железнодорожный транспорт
|
Vehicle for fast travel on rails=Быстрый железнодорожный транспорт
|
||||||
Can be ignited by tools or powered activator rail=Можно воспламенить с помощью инструмента или подключенного рельсового активатора
|
Can be ignited by tools or powered activator rail=Можно воспламенить с помощью инструмента или подключенного рельсового активатора
|
||||||
|
Sneak to dismount=Нажмите [Красться] для высадки
|
||||||
|
|
|
@ -33,3 +33,4 @@ Activates minecarts when powered=
|
||||||
Emits redstone power when a minecart is detected=
|
Emits redstone power when a minecart is detected=
|
||||||
Vehicle for fast travel on rails=
|
Vehicle for fast travel on rails=
|
||||||
Can be ignited by tools or powered activator rail=
|
Can be ignited by tools or powered activator rail=
|
||||||
|
Sneak to dismount=
|
||||||
|
|
Loading…
Reference in a new issue