I ran into an interesting problem while running an experimental entity.
error:
Code: Select all
2017-12-06 15:09:01: ACTION[Server]: singleplayer invokes /spawnentity, entityname="test:basic_mob"
2017-12-06 15:09:01: [Server]: 2
2017-12-06 15:09:01: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'test' in callback luaentity_Step(): Invalid float vector dimension range 'x' (expected -2.14748e+006 < x < 2.14748e+006 got nan).
2017-12-06 15:09:01: ERROR[Main]: stack traceback:
2017-12-06 15:09:01: ERROR[Main]: [C]: in function 'setvelocity'
2017-12-06 15:09:01: ERROR[Main]: ...test-0.4.16-win64\bin\..\games\temple\mods\test\init.lua:50: in function 'set_velocity'
2017-12-06 15:09:01: ERROR[Main]: ...test-0.4.16-win64\bin\..\games\temple\mods\test\init.lua:126: in function 'func'
2017-12-06 15:09:01: ERROR[Main]: ...0.4.16-win64\bin\..\builtin\profiler\instrumentation.lua:106: in function <...0.4.16-win64\bin\..\builtin\profiler\instrumentation.lua:100>
Code: Select all
set_velocity = function(self, v)
local yaw = self.object:getyaw()
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
local x = math.sin(yaw) * -v
local z = math.cos(yaw) * v
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z}) --sometimes crashes because a NaN is passed to x
end,
Code: Select all
minetest.debug(self.run_velocity) --reason for all those 2s
self.set_velocity(self, self.run_velocity)
--and
self.set_velocity(self, 0)
this experimental code was based on PlzAdam's Mobs mod