forked from VoxeLibre/VoxeLibre
Address additional review comments
This commit is contained in:
parent
c33fb223da
commit
70bb65ac1c
|
@ -398,7 +398,7 @@ end
|
||||||
---@param pos Vector
|
---@param pos Vector
|
||||||
---@param src_pos Vector
|
---@param src_pos Vector
|
||||||
function mcl_util.hopper_pull(pos, src_pos)
|
function mcl_util.hopper_pull(pos, src_pos)
|
||||||
return mcl_util.hopper_pull_to_inventory(minetest.get_meta(pos):get_inventory(), 'main', src_pos, pos)
|
return mcl_util.hopper_pull_to_inventory(minetest.get_meta(pos):get_inventory(), "main", src_pos, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drop_item_stack(pos, stack)
|
local function drop_item_stack(pos, stack)
|
||||||
|
|
|
@ -280,7 +280,7 @@ function DEFAULT_CART_DEF:on_step(dtime)
|
||||||
end
|
end
|
||||||
function mod.kill_cart(staticdata, killer)
|
function mod.kill_cart(staticdata, killer)
|
||||||
local pos
|
local pos
|
||||||
minetest.log("action", "cart #"..staticdata.uuid.." was killed")
|
mcl_log("cart #"..staticdata.uuid.." was killed")
|
||||||
|
|
||||||
-- Leave nodes
|
-- Leave nodes
|
||||||
if staticdata.attached_at then
|
if staticdata.attached_at then
|
||||||
|
@ -372,15 +372,15 @@ function mod.place_minecart(itemstack, pointed_thing, placer)
|
||||||
local cart_dir = vector.new(1,0,0)
|
local cart_dir = vector.new(1,0,0)
|
||||||
|
|
||||||
local railpos, node
|
local railpos, node
|
||||||
if mcl_minecarts:is_rail(pointed_thing.under) then
|
if mcl_minecarts.is_rail(pointed_thing.under) then
|
||||||
railpos = pointed_thing.under
|
railpos = pointed_thing.under
|
||||||
elseif mcl_minecarts:is_rail(pointed_thing.above) then
|
elseif mcl_minecarts.is_rail(pointed_thing.above) then
|
||||||
railpos = pointed_thing.above
|
railpos = pointed_thing.above
|
||||||
end
|
end
|
||||||
if railpos then
|
if railpos then
|
||||||
spawn_pos = railpos
|
spawn_pos = railpos
|
||||||
node = minetest.get_node(railpos)
|
node = minetest.get_node(railpos)
|
||||||
cart_dir = mcl_minecarts:get_rail_direction(railpos, vector.new(1,0,0))
|
cart_dir = mcl_minecarts.get_rail_direction(railpos, vector.new(1,0,0))
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity_id = entity_mapping[itemstack:get_name()]
|
local entity_id = entity_mapping[itemstack:get_name()]
|
||||||
|
|
|
@ -74,7 +74,7 @@ end
|
||||||
-- Directional constants
|
-- Directional constants
|
||||||
local north = vector.new( 0, 0, 1); local N = 1 -- 4dir = 0
|
local north = vector.new( 0, 0, 1); local N = 1 -- 4dir = 0
|
||||||
local east = vector.new( 1, 0, 0); local E = 4 -- 4dir = 1
|
local east = vector.new( 1, 0, 0); local E = 4 -- 4dir = 1
|
||||||
local south = vector.new( 0, 0,-1); local S = 2 -- 4dir = 2 Note: S is overwritten below with the translator
|
local south = vector.new( 0, 0,-1); local S = 2 -- 4dir = 2
|
||||||
local west = vector.new(-1, 0, 0); local W = 8 -- 4dir = 3
|
local west = vector.new(-1, 0, 0); local W = 8 -- 4dir = 3
|
||||||
|
|
||||||
-- Share. Consider moving this to some shared location
|
-- Share. Consider moving this to some shared location
|
||||||
|
@ -200,7 +200,7 @@ local function get_rail_connections(pos, opt)
|
||||||
local nodedef = minetest.registered_nodes[node.name]
|
local nodedef = minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
-- Only allow connections to the open ends of rails, as decribed by get_next_dir
|
-- Only allow connections to the open ends of rails, as decribed by get_next_dir
|
||||||
if mcl_minecarts:is_rail(neighbor) and ( legacy or get_path(nodedef, "_mcl_minecarts", "get_next_dir" ) ) then
|
if mcl_minecarts.is_rail(neighbor) and ( legacy or get_path(nodedef, "_mcl_minecarts", "get_next_dir" ) ) then
|
||||||
local rev_dir = vector.direction(dir,vector.zero())
|
local rev_dir = vector.direction(dir,vector.zero())
|
||||||
if ignore_neighbor_connections or is_connection(neighbor, rev_dir) then
|
if ignore_neighbor_connections or is_connection(neighbor, rev_dir) then
|
||||||
connections = bit.bor(connections, bit.lshift(1,i - 1))
|
connections = bit.bor(connections, bit.lshift(1,i - 1))
|
||||||
|
@ -211,7 +211,7 @@ local function get_rail_connections(pos, opt)
|
||||||
local below_neighbor = vector.offset(neighbor, 0, -1, 0)
|
local below_neighbor = vector.offset(neighbor, 0, -1, 0)
|
||||||
local node = force_get_node(below_neighbor)
|
local node = force_get_node(below_neighbor)
|
||||||
local nodedef = minetest.registered_nodes[node.name]
|
local nodedef = minetest.registered_nodes[node.name]
|
||||||
if mcl_minecarts:is_rail(below_neighbor) and ( legacy or get_path(nodedef, "_mcl_minecarts", "get_next_dir" ) ) then
|
if mcl_minecarts.is_rail(below_neighbor) and ( legacy or get_path(nodedef, "_mcl_minecarts", "get_next_dir" ) ) then
|
||||||
local rev_dir = vector.direction(dir, vector.zero())
|
local rev_dir = vector.direction(dir, vector.zero())
|
||||||
if ignore_neighbor_connections or is_connection(below_neighbor, rev_dir) then
|
if ignore_neighbor_connections or is_connection(below_neighbor, rev_dir) then
|
||||||
connections = bit.bor(connections, bit.lshift(1,i - 1))
|
connections = bit.bor(connections, bit.lshift(1,i - 1))
|
||||||
|
@ -280,7 +280,7 @@ local function update_rail_connections(pos, opt)
|
||||||
local dir = CONNECTIONS[i]
|
local dir = CONNECTIONS[i]
|
||||||
local higher_rail_pos = vector.offset(pos,dir.x,1,dir.z)
|
local higher_rail_pos = vector.offset(pos,dir.x,1,dir.z)
|
||||||
local rev_dir = vector.direction(dir,vector.zero())
|
local rev_dir = vector.direction(dir,vector.zero())
|
||||||
if mcl_minecarts:is_rail(higher_rail_pos) and is_connection(higher_rail_pos, rev_dir) then
|
if mcl_minecarts.is_rail(higher_rail_pos) and is_connection(higher_rail_pos, rev_dir) then
|
||||||
make_sloped_if_straight(pos, rev_dir)
|
make_sloped_if_straight(pos, rev_dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -296,10 +296,10 @@ local west = vector.new(-1,0,0)
|
||||||
|
|
||||||
local function is_ahead_slope(pos, dir)
|
local function is_ahead_slope(pos, dir)
|
||||||
local ahead = vector.add(pos,dir)
|
local ahead = vector.add(pos,dir)
|
||||||
if mcl_minecarts:is_rail(ahead) then return false end
|
if mcl_minecarts.is_rail(ahead) then return false end
|
||||||
|
|
||||||
local below = vector.offset(ahead,0,-1,0)
|
local below = vector.offset(ahead,0,-1,0)
|
||||||
if not mcl_minecarts:is_rail(below) then return false end
|
if not mcl_minecarts.is_rail(below) then return false end
|
||||||
|
|
||||||
local node_name = force_get_node(below).name
|
local node_name = force_get_node(below).name
|
||||||
return minetest.get_item_group(node_name, "rail_slope") ~= 0
|
return minetest.get_item_group(node_name, "rail_slope") ~= 0
|
||||||
|
@ -344,8 +344,8 @@ function mcl_minecarts.get_rail_direction(self, pos_, dir)
|
||||||
-- Check both possible diagonal movements
|
-- Check both possible diagonal movements
|
||||||
local dir_a = vector.new(dir.x,0,0)
|
local dir_a = vector.new(dir.x,0,0)
|
||||||
local dir_b = vector.new(0,0,dir.z)
|
local dir_b = vector.new(0,0,dir.z)
|
||||||
local new_dir_a = mcl_minecarts:get_rail_direction(pos, dir_a)
|
local new_dir_a = mcl_minecarts.get_rail_direction(pos, dir_a)
|
||||||
local new_dir_b = mcl_minecarts:get_rail_direction(pos, dir_b)
|
local new_dir_b = mcl_minecarts.get_rail_direction(pos, dir_b)
|
||||||
|
|
||||||
-- If either is the same diagonal direction, continue as you were
|
-- If either is the same diagonal direction, continue as you were
|
||||||
if vector.equals(dir,new_dir_a) or vector.equals(dir,new_dir_b) then
|
if vector.equals(dir,new_dir_a) or vector.equals(dir,new_dir_b) then
|
||||||
|
|
|
@ -179,7 +179,7 @@ local function handle_cart_collision(cart1_staticdata, prev_pos, next_dir)
|
||||||
--print("u1="..tostring(u1)..",u2="..tostring(u2))
|
--print("u1="..tostring(u1)..",u2="..tostring(u2))
|
||||||
if u2 == 0 and u1 < 4 and train_length(cart1_staticdata) < MAX_TRAIN_LENGTH then
|
if u2 == 0 and u1 < 4 and train_length(cart1_staticdata) < MAX_TRAIN_LENGTH then
|
||||||
link_cart_ahead(cart1_staticdata, cart2_staticdata)
|
link_cart_ahead(cart1_staticdata, cart2_staticdata)
|
||||||
cart2_staticdata.dir = mcl_minecarts:get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
|
cart2_staticdata.dir = mcl_minecarts.get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
|
||||||
cart2_staticdata.velocity = cart1_staticdata.velocity
|
cart2_staticdata.velocity = cart1_staticdata.velocity
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -194,7 +194,7 @@ local function handle_cart_collision(cart1_staticdata, prev_pos, next_dir)
|
||||||
cart2_staticdata.velocity = v2
|
cart2_staticdata.velocity = v2
|
||||||
|
|
||||||
-- Force the other cart to move the same direction this one was
|
-- Force the other cart to move the same direction this one was
|
||||||
cart2_staticdata.dir = mcl_minecarts:get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
|
cart2_staticdata.dir = mcl_minecarts.get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function vector_away_from_players(cart, staticdata)
|
local function vector_away_from_players(cart, staticdata)
|
||||||
|
@ -238,7 +238,7 @@ local function direction_away_from_players(staticdata)
|
||||||
if force > 0 then
|
if force > 0 then
|
||||||
dir = -dir
|
dir = -dir
|
||||||
end
|
end
|
||||||
if mcl_minecarts:is_rail( staticdata.connected_at + dir ) then
|
if mcl_minecarts.is_rail( staticdata.connected_at + dir ) then
|
||||||
if force > 0.5 then
|
if force > 0.5 then
|
||||||
return -length * 4
|
return -length * 4
|
||||||
elseif force < -0.5 then
|
elseif force < -0.5 then
|
||||||
|
@ -403,7 +403,7 @@ local function do_movement_step(staticdata, dtime)
|
||||||
staticdata.connected_at = pos
|
staticdata.connected_at = pos
|
||||||
|
|
||||||
-- Get the next direction
|
-- Get the next direction
|
||||||
local next_dir,_ = mcl_minecarts:get_rail_direction(pos, staticdata.dir, nil, nil, staticdata.railtype)
|
local next_dir,_ = mcl_minecarts.get_rail_direction(pos, staticdata.dir, nil, nil, staticdata.railtype)
|
||||||
if DEBUG and next_dir ~= staticdata.dir then
|
if DEBUG and next_dir ~= staticdata.dir then
|
||||||
mcl_debug( "Changing direction from "..tostring(staticdata.dir).." to "..tostring(next_dir))
|
mcl_debug( "Changing direction from "..tostring(staticdata.dir).." to "..tostring(next_dir))
|
||||||
end
|
end
|
||||||
|
|
|
@ -386,6 +386,7 @@ end
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
name = "mcl_minecarts:update_legacy_curvy_rails",
|
name = "mcl_minecarts:update_legacy_curvy_rails",
|
||||||
nodenames = mcl_util.table_keys(CURVY_RAILS_MAP),
|
nodenames = mcl_util.table_keys(CURVY_RAILS_MAP),
|
||||||
|
run_at_every_load = true,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
node.name = CURVY_RAILS_MAP[node.name]
|
node.name = CURVY_RAILS_MAP[node.name]
|
||||||
if node.name then
|
if node.name then
|
||||||
|
|
Loading…
Reference in New Issue