perromercenario wrote: ↑Wed Nov 04, 2020 02:17
how i do something on left click or rigth click or middle click whit the stick ?
To do something
on right click you need to use
on_place function. This function is a callback because it will be passed as an argument to the registration function and will be called there inside and therefore you need to
define it in the table. For on left click there is
on_use callback. There is like no a callback for the middle click.
perromercenario wrote: ↑Wed Nov 04, 2020 02:17
can i get the position xyz from node or entity or whatever was click whit stick ?
Yes, both those functions have
pointed_thing table:
https://github.com/minetest/minetest/bl ... .txt#L1479
perromercenario wrote: ↑Wed Nov 04, 2020 02:17
can i store a value in the item like the position from the last question ?
There is
ItemStackMetaRef interface that used for saving some info and retrieving it from an itemstack:
https://github.com/minetest/minetest/bl ... .txt#L6012 For accessing to that interface you need first to call
itemstack:get_meta():
https://github.com/minetest/minetest/bl ... .txt#L5998 However, if you want to save a table, don`t forget to put it inside
minetest.serialize().
perromercenario wrote: ↑Wed Nov 04, 2020 02:17
can i set a block in the wordl where im clicking whit the stick ?
You need to get above position when clicking and by some way to get a normal to that surface where you have clicked to. If you click on a floor, you can just add '0.5' to 'y' coord of the above:
Code: Select all
local new_pos = {x=pointed_thing.above.x, y=pointed_thing.above.y+0.5, z=pointed_thing.above.z}
and then call
minetest.add_node(new_pos) or
minetest.set_node(new_pos)