Time Nick Message 14:52 Bombo hi can someone help me fixing a bug in a mod? this is the issue: https://github.com/ElCeejo/creatura/issues/35 lines: https://github.com/ElCeejo/creatura/blob/main/mob_meta.lua#L212 i added this: 'if vel.x ~= vel.x then vel.x = 0 end' for x y and z right before self.object:set_velocity() and it seems to not crash anymore but not sure if that made sense 14:55 Bombo adding a minetest.log shows it happens a lot that it is NaN 14:57 [MatrxMT] it's kind of a band-aid solution. It fixes a NaN after it's happened, instead of at the cause. The stack trace might be able to tell you where it came form 15:01 [MatrxMT] something's a bit suspicious about using the `and` keyword and the `or keyword` on floating point values in the first place. It's very rare in floating point to get an exact 0 figure 15:02 [MatrxMT] well, that's used because `data` might have a falsy value. That sounds like a lack of initialization problem.. 15:03 Bombo yes band aid, that's why i'm asking for help here ;) 15:03 [MatrxMT] the 0 number is still true as bool? 15:04 Bombo i don't know too much about lua, still learning 15:05 [MatrxMT] `if 0.0 then print('boo') end` -> prints it. Yeah, 0.0 isn't falsy. But it seems more like it's there to guarantee init 15:08 [MatrxMT] Bombo: the original reporter didn't have any more stack trace. Do you also not have any more stack trace? 15:09 Bombo original reporter is me ;) 15:09 [MatrxMT] oic 15:09 Bombo no thats the only stack trace 15:10 Bombo server shutting down, then these lnes show up 15:13 Bombo i can add more minetest.log to check values 15:15 [MatrxMT] how many birds in the box and how long? 15:17 Bombo i spawned 10 but it really depends, right now it happens right when i join, yesterday i had to wait 30min 15:17 MTDiscord you need to trace the data flow back: where did the NaNs first arise? what populates self._movement_data? 15:20 [MatrxMT] an owl came and ate my testing birds 15:20 Bombo hnm if its not a number what is it, isn't there a way to find that out? or get an error msg why its a nan 15:20 Bombo happens hehe 15:22 [MatrxMT] any time you do floating point maths, there's a chance it comes out to NaN. Usually if you try to divide by zero. There's no immediate warning and no easy way to track it back to where it happened, it just turns everything it does arithmetic with into also NaNs until something handles it or crashes 15:28 Bombo there were no nans for 15mins, all the birds were eaten, then i spawned one only and it started again 15:28 Bombo now i restarted the server, 10 birds, non nans hmm 15:32 [MatrxMT] creatura/boids.lua function creatura.get_boid_dir(self) 15:33 [MatrxMT] there's a division by lift_no and at the top of the function it's initialized to 0. So there's the chance it stays that way if the ipairs() loop never runs. Don't know the odds of that 15:35 [MatrxMT] "boids" is a flock simulation that's common in programming by the way. It would be to get the songbirds to fly as a flock together 16:01 Bombo hm i get 'attempt to concatenate vert_vel (a nil value)' when i tried to minetest.log with "vertvel is: "..vert_vel or "nothing".. 16:02 Bombo shouldnt that print nothing if vert_vel is nil? 16:04 calculon looks like it needs parenthesis: "vertvel is: "..(vert_vel or "nothing").. 16:56 Bombo ah nice, well its nothing 17:16 calculon btw "if its not a number what is it" -> funnily not a number is a number :) 17:16 calculon ie it's a value with type "number" 17:17 calculon and you can check if a value is nan with if x ~= x (because nan is never equal to another nan) 19:42 pgimeno you only get NaN for 0/0, not for other values /0, for those you get infinity 19:49 Krock how about -NaN? 19:50 pgimeno I'm not sure if Lua produces -NaN, that's indeterminate as opposed to not a number, but it's very platform-dependent 19:50 user333_ player:set_pos({x=nan, y=nan, z=nan}) 19:51 pgimeno 0/0 is -nan; sqrt(-1) is nan 19:51 Krock so nan * nan = -1? 19:51 Krock unfortunately it propagates 19:51 pgimeno no :) nan * nan = nan 19:51 pgimeno yeah 19:52 user333_ nan * nil 19:55 pgimeno $ luajit -> =0/0 -> nan 19:55 pgimeno $ lua -> =0/0 -> -nan 19:57 pgimeno actually in puc lua, math.sqrt(-1) produces -nan in my system, but math.acos(2) produces nan 20:52 MTDiscord Which is generally preferred: Using an item/node full name or alias in a crafting recipe. 20:52 MTDiscord Both work, just wanted to know if there was a standard.