[solved] Can you detect node and get its location
I am making a mod which detects the node above it and if its air it replaces it with a node.
so lets say I have a node (default:dirt) at 0,0,0
when i hit this done (with on_punch) it checks the node at 0,1,0
After this it checks what the node at 0,1,0 and if its air it places a node there (default:dirt)
What i have tried'
The code above works but you cannot put two nodes together since since it looks for the dirt in X, Y and Z
So if i place a node at 0,0,0 then hit it it will place a node at 0,1,0
However if i place a node at 0,0,1 it will detect the node at 0,0,0 and 0,1,0 and not place a node.
I have also the code shown below but it just crashes the game
If anyone knows how to solve the problem feel free to reply.
many thanks
so lets say I have a node (default:dirt) at 0,0,0
when i hit this done (with on_punch) it checks the node at 0,1,0
After this it checks what the node at 0,1,0 and if its air it places a node there (default:dirt)
What i have tried'
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
pos.y = pos.y + 1;
if minetest.find_node_near(
{x = pos.x, y = pos.y + height, z = pos.z }, 1, {"default:dirt"}) then
The code above works but you cannot put two nodes together since since it looks for the dirt in X, Y and Z
So if i place a node at 0,0,0 then hit it it will place a node at 0,1,0
However if i place a node at 0,0,1 it will detect the node at 0,0,0 and 0,1,0 and not place a node.
I have also the code shown below but it just crashes the game
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
if minetest.find_node_in_area(
{x = pos.x, y = pos.y, z = pos.z },
{x = pos.x, y = pos.y, z = pos.z },
{"scaffolding:scaffolding"}) then
If anyone knows how to solve the problem feel free to reply.
many thanks