Allow cart exit with jump key
parent
e587efc2b8
commit
3afac50041
|
@ -217,9 +217,20 @@ local function on_step(self, dtime)
|
||||||
recording_waypoints(self)
|
recording_waypoints(self)
|
||||||
self.rec_time = self.rec_time + 2.0
|
self.rec_time = self.rec_time + 2.0
|
||||||
end
|
end
|
||||||
recording_junctions(self)
|
if recording_junctions(self) then
|
||||||
|
local pos = vector.round(self.object:get_pos())
|
||||||
|
minecart.stop_recording(self, pos, true)
|
||||||
|
local player = minetest.get_player_by_name(self.driver)
|
||||||
|
minecart.manage_attachment(player, self, false)
|
||||||
|
minecart.entity_to_node(pos, self)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
player_ctrl(self)
|
if player_ctrl(self) then
|
||||||
|
local pos = vector.round(self.object:get_pos())
|
||||||
|
local player = minetest.get_player_by_name(self.driver)
|
||||||
|
minecart.manage_attachment(player, self, false)
|
||||||
|
minecart.entity_to_node(pos, self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -241,7 +252,7 @@ local function on_entitycard_punch(self, puncher, time_from_last_punch, tool_cap
|
||||||
-- Dig cart
|
-- Dig cart
|
||||||
if self.driver then
|
if self.driver then
|
||||||
-- remove cart as driver
|
-- remove cart as driver
|
||||||
minecart.stop_recording(self, pos)
|
minecart.stop_recording(self, pos, true)
|
||||||
minecart.monitoring_remove_cart(self.owner, self.userID)
|
minecart.monitoring_remove_cart(self.owner, self.userID)
|
||||||
minecart.remove_entity(self, pos, puncher)
|
minecart.remove_entity(self, pos, puncher)
|
||||||
minecart.manage_attachment(puncher, self, false)
|
minecart.manage_attachment(puncher, self, false)
|
||||||
|
@ -273,12 +284,13 @@ local function on_entitycard_rightclick(self, clicker)
|
||||||
if self.driver then
|
if self.driver then
|
||||||
-- get off
|
-- get off
|
||||||
local pos = vector.round(self.object:get_pos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
|
minecart.stop_recording(self, pos, true)
|
||||||
minecart.manage_attachment(clicker, self, false)
|
minecart.manage_attachment(clicker, self, false)
|
||||||
minecart.entity_to_node(pos, self)
|
minecart.entity_to_node(pos, self)
|
||||||
else
|
else
|
||||||
-- get on
|
-- get on
|
||||||
local pos = vector.round(self.object:get_pos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
minecart.stop_recording(self, pos)
|
minecart.stop_recording(self, pos, true)
|
||||||
minecart.manage_attachment(clicker, self, true)
|
minecart.manage_attachment(clicker, self, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -103,12 +103,14 @@ function minecart.start_recording(self, pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function minecart.stop_recording(self, pos)
|
function minecart.stop_recording(self, pos, force_exit)
|
||||||
--print("stop_recording")
|
--print("stop_recording")
|
||||||
if self.driver and self.is_recording then
|
if self.driver and self.is_recording then
|
||||||
local dest_pos = minecart.get_buffer_pos(pos, self.driver)
|
local dest_pos = minecart.get_buffer_pos(pos, self.driver)
|
||||||
local player = minetest.get_player_by_name(self.driver)
|
local player = minetest.get_player_by_name(self.driver)
|
||||||
if dest_pos and player and #self.checkpoints > 3 then
|
if force_exit then
|
||||||
|
minetest.chat_send_player(self.driver, S("[minecart] Recording canceled!"))
|
||||||
|
elseif dest_pos and player and #self.checkpoints > 3 then
|
||||||
-- Remove last checkpoint, because it is potentially too close to the dest_pos
|
-- Remove last checkpoint, because it is potentially too close to the dest_pos
|
||||||
table.remove(self.checkpoints)
|
table.remove(self.checkpoints)
|
||||||
if self.start_pos then
|
if self.start_pos then
|
||||||
|
@ -163,6 +165,8 @@ function minecart.recording_junctions(self)
|
||||||
self.ctrl = {right = true}
|
self.ctrl = {right = true}
|
||||||
elseif ctrl.up or ctrl.down then
|
elseif ctrl.up or ctrl.down then
|
||||||
self.ctrl = nil
|
self.ctrl = nil
|
||||||
|
elseif ctrl.jump then
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.hud_time <= self.timebase then
|
if self.hud_time <= self.timebase then
|
||||||
|
@ -186,6 +190,8 @@ function minecart.player_ctrl(self)
|
||||||
self.ctrl = {left = true}
|
self.ctrl = {left = true}
|
||||||
elseif ctrl.right then
|
elseif ctrl.right then
|
||||||
self.ctrl = {right = true}
|
self.ctrl = {right = true}
|
||||||
|
elseif ctrl.jump then
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue