Page 1 of 1

Something weird about moveresult.collisions

Posted: Sat Feb 06, 2021 11:41
by davidthecreator
I tried to use moveresult.collisions.type to check if an object is colliding with a node or other object, but it wouldn't work... Untill I used a minetest.serialize() trick to check what the full table looks like and noticed that it's properties are stored in double table brackets {{ }}
While hpchange for example, uses single table brackets {}, so the feature that I need, only works if I write it like:

moveresult.collisions[1].type

And having to use [1] seems a little weird, considering it seems to be the only element in "collisions" table aniway...

So is it intentional, or will it be changed in near future?

Re: Something weird about moveresult.collisions

Posted: Sat Feb 06, 2021 12:06
by Termos
It only happens to be the only element most of the time, but occasionally there can be up to three elements (one for each axis) and theoretically even more when bouncy nodes are involved.
Yes this is intentional.