Page 1 of 1

Can I get the face of a punched node?

PostPosted: Mon May 16, 2016 14:31
by burli
I want to know, which face of a node is punched. Or, even better, the position on the face. Is that possible?

Re: Can I get the face of a punched node?

PostPosted: Mon May 16, 2016 19:56
by kaeza
There's no function in the engine ATM, but you may find this SO question useful.

Edit: If you only need the face, you can take a shortcut by comparing the `above` and `under` fields of the `pointed_thing` parameter to `on_punch`: `under` refers to the node itself, while `above` refers to the pos of the node that would be "against" the clicked face (not necessarily in the +Y direction).

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local u, a = pt.under, pt.above
if u.x<a.x then -- Clicked on +X (i.e. east or right face)
elseif u.x>a.x then -- Clicked on -X (i.e. west or left face)
-- and so on for (+/-)(Y/Z)


Edit 2: Also note that the above does not take into account any possible node rotation.

HTH

Re: Can I get the face of a punched node?

PostPosted: Tue May 17, 2016 21:05
by burli
The identify mod makes something similar. I guess I can use this