Page 1 of 1

Set facedir in minetest.place_node function

PostPosted: Thu Jun 30, 2016 02:51
by Hasan
I am beginner with minetest modding and i want to know if it is possible to set the node's facedir when using the minetest.place_node function, i am using this it to replace a node with another node

Example: if the player right-click on a dirt node it will be changed to a cobble stairs node, but the problem is that i want it to be in the direction of the player exactly if he placed it normaly with right-click.

is it possible to do this with the current minetest version or it needs an engine update (etc.....)?

Re: Set facedir in minetest.place_node function

PostPosted: Thu Jun 30, 2016 19:43
by LNJ
Hasan wrote:I am beginner with minetest modding and i want to know if it is possible to set the node's facedir when using the minetest.place_node function, i am using this it to replace a node with another node

Example: if the player right-click on a dirt node it will be changed to a cobble stairs node, but the problem is that i want it to be in the direction of the player exactly if he placed it normaly with right-click.

is it possible to do this with the current minetest version or it needs an engine update (etc.....)?

I think (I never tried this, sry if I am wrong) you should first get the player (who does this action), then get his look dir and convert it to a facedir (for the node) and then you can set the node with core.set_node.

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 lookdir = player:get_look_dir()
local facedir = core.dir_to_facedir(lookdir)

core.set_node(pos, {name = "default:dirt", param2 = facedir})


And may also have a look at https://dev.minetest.net/, http://dev.minetest.net/Player, http://dev.minetest.net/minetest.dir_to_facedir and maybe also http://dev.minetest.net/Category:Methods

PS: You should better post such things in the modding discussion subforum.

Re: Set facedir in minetest.place_node function

PostPosted: Thu Jun 30, 2016 20:04
by Hasan
Thx a lot you really solved my problem
I completely ignored this function (get player name etc....)
Thx i spent a lot of time to find it