Remove instance of debug logging, change movement.lua function export

This commit is contained in:
teknomunk 2024-10-29 07:45:00 -05:00
parent 7f69e6ab9e
commit 61a2f98b2b
2 changed files with 12 additions and 11 deletions

View File

@ -13,10 +13,10 @@ local save_cart_data = mod.save_cart_data
local update_cart_data = mod.update_cart_data local update_cart_data = mod.update_cart_data
local destroy_cart_data = mod.destroy_cart_data local destroy_cart_data = mod.destroy_cart_data
local find_carts_by_block_map = mod.find_carts_by_block_map local find_carts_by_block_map = mod.find_carts_by_block_map
local do_movement,do_detached_movement,handle_cart_enter = dofile(modpath.."/movement.lua") local movement = dofile(modpath.."/movement.lua")
assert(do_movement) assert(movement.do_movement)
assert(do_detached_movement) assert(movement.do_detached_movement)
assert(handle_cart_enter) assert(movement.handle_cart_enter)
-- Constants -- Constants
local max_step_distance = 0.5 local max_step_distance = 0.5
@ -345,7 +345,7 @@ function DEFAULT_CART_DEF:on_step(dtime)
if not staticdata.connected_at then if not staticdata.connected_at then
do_detached_movement(self, dtime) movement.do_detached_movement(self, dtime)
else else
mod.update_cart_orientation(self) mod.update_cart_orientation(self)
end end
@ -407,7 +407,7 @@ function mod.place_minecart(itemstack, pointed_thing, placer)
end end
if railpos then if railpos then
handle_cart_enter(staticdata, railpos) movement.handle_cart_enter(staticdata, railpos)
end end
local pname = placer and placer:get_player_name() or "" local pname = placer and placer:get_player_name() or ""
@ -619,7 +619,7 @@ minetest.register_globalstep(function(dtime)
--- Non-entity code --- Non-entity code
if staticdata.connected_at then if staticdata.connected_at then
do_movement(staticdata, dtime) movement.do_movement(staticdata, dtime)
end end
end end

View File

@ -2,6 +2,7 @@ local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local mod = mcl_minecarts local mod = mcl_minecarts
local S = minetest.get_translator(modname) local S = minetest.get_translator(modname)
local submod = {}
-- Constants -- Constants
local mcl_debug,DEBUG = mcl_util.make_mcl_logger("mcl_logging_minecart_debug", "Minecart Debug") local mcl_debug,DEBUG = mcl_util.make_mcl_logger("mcl_logging_minecart_debug", "Minecart Debug")
@ -92,6 +93,7 @@ local function handle_cart_enter(staticdata, pos, next_dir)
set_metadata_cart_status(pos, staticdata.uuid, 1) set_metadata_cart_status(pos, staticdata.uuid, 1)
handle_cart_enter_exit(staticdata, pos, next_dir, "on_enter" ) handle_cart_enter_exit(staticdata, pos, next_dir, "on_enter" )
end end
submod.handle_cart_enter = handle_cart_enter
local function handle_cart_leave(staticdata, pos, next_dir) local function handle_cart_leave(staticdata, pos, next_dir)
--print("leaving "..tostring(pos)) --print("leaving "..tostring(pos))
set_metadata_cart_status(pos, staticdata.uuid, nil) set_metadata_cart_status(pos, staticdata.uuid, nil)
@ -476,7 +478,7 @@ local function do_movement_step(staticdata, dtime)
return dtime - timestep return dtime - timestep
end end
local function do_movement( staticdata, dtime ) function submod.do_movement( staticdata, dtime )
assert(staticdata) assert(staticdata)
-- Allow the carts to be delay for the rest of the world to react before moving again -- Allow the carts to be delay for the rest of the world to react before moving again
@ -504,7 +506,7 @@ local function do_movement( staticdata, dtime )
end end
end end
local function do_detached_movement(self, dtime) function submod.do_detached_movement(self, dtime)
local staticdata = self._staticdata local staticdata = self._staticdata
-- Make sure the object is still valid before trying to move it -- Make sure the object is still valid before trying to move it
@ -575,11 +577,10 @@ local function do_detached_movement(self, dtime)
-- Reset pitch if still not attached -- Reset pitch if still not attached
local rot = self.object:get_rotation() local rot = self.object:get_rotation()
minetest.log(vector.to_string(rot))
rot.x = 0 rot.x = 0
self.object:set_rotation(rot) self.object:set_rotation(rot)
end end
--return do_movement, do_detatched_movement --return do_movement, do_detatched_movement
return do_movement,do_detached_movement,handle_cart_enter return submod