Problem to compare node in mod

Post Reply
Futuray-pgm
Member
Posts: 14
Joined: Wed Mar 29, 2023 07:08
GitHub: Futuray-pgm
IRC: Futuray-pgm
In-game: Futuray
Location: France
Contact:

Problem to compare node in mod

by Futuray-pgm » Post

Hello,
I create a minetest mod (content.minetest.net/packages/Futuray-pgm/magic_tech) and I would to know if the pointed node is a stone block. But it dosn't work and I didn't find the problem.

Code: Select all

activated_wand.use = function(itemstack, user, pointed)
	local pointed_node = minetest.get_node(pointed.under).name
	if pointed_node == "default:stone" then
		minetest.place_node(pointed.under, {name = "magic_tech:infested_stone"})
	end
	return 
end
Can somebody help me ?
Futuray

Futuray-pgm
Member
Posts: 14
Joined: Wed Mar 29, 2023 07:08
GitHub: Futuray-pgm
IRC: Futuray-pgm
In-game: Futuray
Location: France
Contact:

Re: Problem to compare node in mod

by Futuray-pgm » Post

Sorry, I've made little tests and the problem is in the place_node function.
But it still doesn't work. 😭
Futuray

User avatar
cx384
Member
Posts: 655
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Problem to compare node in mod

by cx384 » Post

You can't use place_node for this, since it actually places the node like a player and you can't just place it inside the stone node.
https://github.com/minetest/minetest/bl ... .txt#L5569

To fix this you need to set the node with minetest.set_node(pointed.under, {name = "magic_tech:infested_stone"}) or alternatively remove it first (with e.g dig_node).
https://github.com/minetest/minetest/bl ... .txt#L5519
Can your read this?

Futuray-pgm
Member
Posts: 14
Joined: Wed Mar 29, 2023 07:08
GitHub: Futuray-pgm
IRC: Futuray-pgm
In-game: Futuray
Location: France
Contact:

Re: Problem to compare node in mod

by Futuray-pgm » Post

It work's!!!! 🎉🎉
Thank you very much 😀
Futuray

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests