Set facedir in minetest.place_node function

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

Set facedir in minetest.place_node function

by Hasan » Thu Jun 30, 2016 02:51

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.....)?
 

User avatar
LNJ
Member
 
Posts: 200
Joined: Tue Sep 23, 2014 16:02
GitHub: LNJ2
IRC: LNJ2GO
In-game: LNJ

Re: Set facedir in minetest.place_node function

by LNJ » Thu Jun 30, 2016 19:43

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.
My Minetest Modding Tutorials (German) | Minetest TNG - My survival subgame! (OUTDATED... :() | #ComeToTheDuckSide - we have privacy! | diaspora* - The free and decentralized alternative to facebook and twitter!
 

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

Re: Set facedir in minetest.place_node function

by Hasan » Thu Jun 30, 2016 20:04

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
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 9 guests

cron