Get node direction as a number

Hasan
Member
 
Posts: 30
Joined: Mon Oct 12, 2015 14:50
IRC: Hasan2

Get node direction as a number

by Hasan » Mon Aug 01, 2016 09:07

Hello, is it possible to get the node direction as a number, example: the node direction at the point (0,0,0) is (-270)

is it possible to get this?
 

User avatar
Naj
Member
 
Posts: 170
Joined: Sat Sep 19, 2015 21:14
GitHub: pyrollo
In-game: naj

Re: Get node direction as a number

by Naj » Mon Aug 01, 2016 09:45

Sorry but what do you mean by "node direction" ?
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Get node direction as a number

by rubenwardy » Mon Aug 01, 2016 11:17

Do you mean angle around the y axis?
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Get node direction as a number

by ozkur » Mon Aug 01, 2016 14:55

you mean is it pointing left, right, up, down, forwards, or backwards?
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

DcNdrew
Member
 
Posts: 14
Joined: Tue Jul 26, 2016 03:12

Re: Get node direction as a number

by DcNdrew » Mon Aug 01, 2016 16:02

He asks where does the node is facing. North, south, east, west etc. It must be possible in a way.
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Get node direction as a number

by ozkur » Mon Aug 01, 2016 17:10

minetest has to call it every single time it draws, right?
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Get node direction as a number

by Krock » Mon Aug 01, 2016 20:08

Hasan wrote:the node direction at the point (0,0,0) is (-270)

I assume you want to get the rotation, then you can use this code:
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
-- Get node data
local node = minetest.get_node(vector.new(0, 0, 0))
-- Get dir as vector (x, y, z), but only read the x and z axis (modulo 4)
local dir = minetest.facedir_to_dir(node.param2 % 4)

-- Calculate dir to angle UNTESTED
local angle = 0
if dir.z == 1 then
   angle = 90
elseif dir.x == -1 then
   angle = 180
elseif dir.z == -1 then
   angle = 270
end
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

Hasan
Member
 
Posts: 30
Joined: Mon Oct 12, 2015 14:50
IRC: Hasan2

Re: Get node direction as a number

by Hasan » Mon Aug 01, 2016 20:26

@Naj: i mean the node angel which is only 4 directions i think it is 0, 90, 180, 270
@rubenwardy: yeah that what i was mean
@Krock: i will try your code and tell you about the result

And thank you all guys ;)
 

Hasan
Member
 
Posts: 30
Joined: Mon Oct 12, 2015 14:50
IRC: Hasan2

Re: Get node direction as a number

by Hasan » Mon Aug 01, 2016 20:35

Krock wrote:
Hasan wrote:the node direction at the point (0,0,0) is (-270)

I assume you want to get the rotation, then you can use this code:
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
-- Get node data
local node = minetest.get_node(vector.new(0, 0, 0))
-- Get dir as vector (x, y, z), but only read the x and z axis (modulo 4)
local dir = minetest.facedir_to_dir(node.param2 % 4)

-- Calculate dir to angle UNTESTED
local angle = 0
if dir.z == 1 then
   angle = 90
elseif dir.x == -1 then
   angle = 180
elseif dir.z == -1 then
   angle = 270
end


Thank you very much Krock, that what i needed indeed!
Thank you all guys.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron