diff --git a/wagons.lua b/wagons.lua index 6944e76..287b723 100644 --- a/wagons.lua +++ b/wagons.lua @@ -174,6 +174,12 @@ end function wagon:on_step(dtime) local t=os.clock() local pos = self.object:getpos() + + if not pos then + print("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)") + return + end + if not self.initialized_pre then print("[advtrains] wagon stepping while not yet initialized_pre, returning") self.object:setvelocity({x=0,y=0,z=0}) @@ -269,6 +275,10 @@ function wagon:on_step(dtime) self.object:setvelocity({x=0, y=0, z=0}) return end + if not self.pos_in_train then + print("["..self.unique_id.."][fatal] no pos_in_train set.") + return + end local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) --print("trainindex "..gp.index.." wagonindex "..index)