Fix crashes, fix link in documentation

This commit is contained in:
teknomunk 2024-04-11 09:17:06 +00:00
parent db2c200136
commit a149ef5f05
4 changed files with 7 additions and 7 deletions

View file

@ -33,7 +33,7 @@ Processing for minecart movement is as follows:
4. The cart checks for nearby carts and collides elastically with these. The
calculations for these collisions are in the function `handle_cart_collision`
5. If the cart enters a new block, determine the new direction the cart will
move with `mcl_minecarts:get_rail_direction` in [functions.lua](./functions.lua].
move with `mcl_minecarts:get_rail_direction` in [functions.lua](./functions.lua).
The rail nodes provide a hook `_mcl_minecarts.get_next_direction` that
provides this information based on the previous movement direction.
3. If an entity exists for a given cart, the entity will update its position

View file

@ -5,7 +5,7 @@ local mod = mcl_minecarts
mcl_minecarts.modpath = modpath
-- Constants
mod.speed_max = 10
mod.SPEED_MAX = 10
mod.FRICTION = 0.4
mod.MAX_TRAIN_LENGTH = 4
mod.CART_BLOCK_SIZE = 64

View file

@ -240,7 +240,6 @@ local function calculate_acceleration(staticdata)
local pos = staticdata.connected_at
local node_name = minetest.get_node(pos).name
local node_def = minetest.registered_nodes[node_name]
local max_vel = SPEED_MAX
local ctrl = staticdata.controls or {}
local time_active = minetest.get_gametime() - 0.25
@ -251,7 +250,7 @@ local function calculate_acceleration(staticdata)
acceleration = -1.5
elseif (staticdata.fueltime or 0) > 0 and staticdata.velocity <= 4 then
acceleration = 0.6
elseif staticdata.velocity >= ( node_def._max_acceleration_velocity or max_vel ) then
elseif staticdata.velocity >= ( node_def._max_acceleration_velocity or SPEED_MAX ) then
-- Standard friction
elseif node_def and node_def._rail_acceleration then
acceleration = node_def._rail_acceleration * 4

View file

@ -3,6 +3,7 @@ local mod = mcl_minecarts
-- Imports
local CART_BLOCK_SIZE = mod.CART_BLOCK_SIZE
assert(CART_BLOCK_SIZE)
local cart_data = {}
local cart_data_fail_cache = {}
@ -72,9 +73,9 @@ function mod.find_carts_by_block_map(block_map)
return cart_list
end
function mod.add_block_map(block_map, min_pos, max_pos)
local min = vector.floor(vector.divide(min_pos), CART_BLOCK_SIZE)
local max = vector.floor(vector.divide(max_pos), CART_BLOCK_SIZE) + vector.new(1,1,1)
function mod.add_blocks_to_map(block_map, min_pos, max_pos)
local min = vector.floor(vector.divide(min_pos, CART_BLOCK_SIZE))
local max = vector.floor(vector.divide(max_pos, CART_BLOCK_SIZE)) + vector.new(1,1,1)
for z = min.z,max.z do
for y = min.y,max.y do
for x = min.x,max.x do