From f4c1a2ec3b4bd23c32e7ecb1f9eaf5c754632545 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 15 Jan 2018 18:41:40 +0100 Subject: [PATCH] Fix edge case crash due nil old_pos, remove player_api warning --- cart_entity.lua | 3 ++- init.lua | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cart_entity.lua b/cart_entity.lua index 02436fb..01c6315 100644 --- a/cart_entity.lua +++ b/cart_entity.lua @@ -220,7 +220,8 @@ function cart_entity:on_step(dtime) if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then vel = {x=0, y=0, z=0} local pos_r = vector.round(pos) - if not boost_cart:is_rail(pos_r, self.railtype) then + if not boost_cart:is_rail(pos_r, self.railtype) + and self.old_pos then pos = self.old_pos elseif not stop_wiggle then pos = pos_r diff --git a/init.lua b/init.lua index 755ab9d..7230ca0 100644 --- a/init.lua +++ b/init.lua @@ -25,8 +25,8 @@ if not default.player_attached then default.player_attached = {} end -minetest.after(1, function() - boost_cart.old_player_model = type(player_api) ~= "table" +minetest.after(0.5, function() + boost_cart.old_player_model = not minetest.global_exists("player_api") end) dofile(boost_cart.modpath.."/functions.lua")