Block that place other blocks
Block that place other blocks
I will make a mod with a node. I want that the node place other blocks, but I don't know how I can make this. Can who say me how???
X17
X17
Re: Block that place other blocks
This is how beds mod places 2 nodes after a bed is placed: https://github.com/minetest/minetest_ga ... pi.lua#L50
Re: Block that place other blocks
Do you mean "minetest.set_node"?
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Block that place other blocks
You could use after_place_node in your node's definition to do something after the node was placed. There you can invoke minetest.set_node() to set a specific node in a specific location.
Re: Block that place other blocks
So I must write "after_place_node = {minetest.set_node(name = "ITEMNAME")},"?
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Block that place other blocks
You must read the API :) I even linked the relevant part.
How to handle the parameters/variables is also described in the API documentation.
Code: Select all
minetest.register_node('modname:nodename', {
[... node definition stuff ...]
after_place_node = function(pos, placer, itemstack, pointed_thing)
-- do whatever you want here. You have access to the placed node's position,
-- the player who placed the node, the itemstack and the thing the node was
-- placed against.
end,
[... node definition stuff ...]
})
Re: Block that place other blocks
What I must write when I want that the second block is on my block? y=1 ??
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Block that place other blocks
In the function you have access to the position of the node you placed. pos is a table containing x, y, z as entries. You need to place your new node at pos.y-1.
Again: everything you need is fully documented in lua_api.txt.
Code: Select all
minetest.set_node({ x = pos.x, y = pos.y-1, z = pos.z }, { name = 'mymod:mynode' })
Who is online
Users browsing this forum: No registered users and 5 guests