Can I get the face of a punched node?

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Can I get the face of a punched node?

by burli » Mon May 16, 2016 14:31

I want to know, which face of a node is punched. Or, even better, the position on the face. Is that possible?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

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

by kaeza » Mon May 16, 2016 19:56

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
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Tue May 17, 2016 21:05

The identify mod makes something similar. I guess I can use this
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 11 guests

cron