Load the travelnet node before performing teleport logic on it (#27)
* Move load retrying from the rotate_player method to outside of the existance check
This commit is contained in:
parent
6f170053da
commit
48f46d2985
@ -227,16 +227,9 @@ function travelnet.open_close_door(pos, player, mode)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
travelnet.rotate_player = function(target_pos, player, tries)
|
||||
-- try later when the box is loaded
|
||||
travelnet.rotate_player = function(target_pos, player)
|
||||
local target_node = minetest.get_node_or_nil(target_pos)
|
||||
if target_node == nil then
|
||||
if tries < 30 then
|
||||
minetest.after(0, travelnet.rotate_player, target_pos, player, tries+1)
|
||||
end
|
||||
return
|
||||
end
|
||||
if target_node == nil then return end
|
||||
|
||||
-- play sound at the target position as well
|
||||
if travelnet.travelnet_sound_enabled then
|
||||
@ -598,4 +591,3 @@ travelnet.can_dig = function()
|
||||
-- forbid digging of the travelnet
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -190,30 +190,27 @@ function travelnet.on_receive_fields(pos, _, fields, player)
|
||||
end
|
||||
end
|
||||
|
||||
player:move_to(vector.add(target_pos, player_model_vec), false)
|
||||
minetest.load_area(target_pos)
|
||||
|
||||
-- check if the box has at the other end has been removed.
|
||||
local target_node = minetest.get_node_or_nil(target_pos)
|
||||
if target_node ~= nil then
|
||||
local target_node_def = minetest.registered_nodes[target_node.name]
|
||||
local has_travelnet_group = target_node_def.groups.travelnet or target_node_def.groups.elevator
|
||||
local target_node = minetest.get_node(target_pos)
|
||||
local target_node_def = minetest.registered_nodes[target_node.name]
|
||||
local has_travelnet_group = target_node_def.groups.travelnet or target_node_def.groups.elevator
|
||||
|
||||
if not has_travelnet_group then
|
||||
-- provide information necessary to identify the removed box
|
||||
local oldmetadata = {
|
||||
fields = {
|
||||
owner = owner_name,
|
||||
station_name = fields.target,
|
||||
station_network = station_network
|
||||
}
|
||||
if not has_travelnet_group then
|
||||
-- provide information necessary to identify the removed box
|
||||
local oldmetadata = {
|
||||
fields = {
|
||||
owner = owner_name,
|
||||
station_name = fields.target,
|
||||
station_network = station_network
|
||||
}
|
||||
}
|
||||
|
||||
travelnet.remove_box(target_pos, nil, oldmetadata, player)
|
||||
-- send the player back as there's no receiving travelnet
|
||||
player:move_to(pos, false)
|
||||
else
|
||||
travelnet.rotate_player(target_pos, player, 0)
|
||||
end
|
||||
travelnet.remove_box(target_pos, nil, oldmetadata, player)
|
||||
else
|
||||
player:move_to(vector.add(target_pos, player_model_vec), false)
|
||||
travelnet.rotate_player(target_pos, player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user