[SOLVED] Place against surface, have after_place_node called

Post Reply
entuland
Member
Posts: 123
Joined: Wed May 09, 2018 15:47
GitHub: entuland
IRC: entuland
In-game: entuland

[SOLVED] Place against surface, have after_place_node called

by entuland » Post

Hello there,
I'm stumbling on a problem with my mod.

The scenario is this: I have a working textured mesh that takes about 1/4 of a full node (it's a pad), I want to to be able to place it against the floor, the wall or the ceiling depending on the pointed to surface.

Inspecting other mods seems like this requires me to set, in register_node, "paramtype2" to "facedir" and to bind "on_place" to "minetest.rotate_node" - and in fact that somehow works, the node gets placed and properly rotated.

Problem is that I also need my "after_place_node" callback run in order to alter the node metas, and even though I see no reason in the builtin Lua for that (I'm running 0.4.16), that callback doesn't get called.

If I avoid binding "on_place" to "minetest.rotate_node", then my "after_place_node" gets run correctly (but then, the node doesn't get properly rotated according to the pointed-to surface)

What am I missing? Any workaround I could try?
Last edited by entuland on Thu May 10, 2018 17:12, edited 2 times in total.

entuland
Member
Posts: 123
Joined: Wed May 09, 2018 15:47
GitHub: entuland
IRC: entuland
In-game: entuland

Re: Place against surface _and_ have after_place_node called

by entuland » Post

I managed to fix my code working around the issue with the help of Krock on IRC.

I got rid of on_construct() and after_place_node() altogether, now everything happens in on_place().

For some reason on_place() gets called even when I right click on one of the existing pads (even though I registered on_rightclick()) and for that reason I have to intercept such case and avoid saving a new pad in case of such right clicks (checking whether the pointed_to.under node is actually one of my pads)

That said, I think I can consider this issue worked around.

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 11 guests