by Sokomine » Thu Dec 20, 2012 18:00
on_use seems to be intended for those cases when the item is used (e.g. a block placed). When a right-click happens to a node, the formspec is displayed (if there is one). Catching the click and changing the formspec depending on who clicked does not seem possible from lua. Only when the player inputs something into the formspec is a time when your function can plug in.
With lua entities, the situation is more or less reverse; they don't support formpsec menus and just offer a function on right click. I'd like to show a formspec menu (diffrent menu depending on who clicked on the npc) so as to talk to the npc and exchange inventory. This is currently not possible on the lua level. On the c++ level, it requires more knowled ge about data structures and the way things are done than I currently have. Furthermore, right-click on a node is handled more or less by the client alone, while right-click on lua objects is handled by the server. It's the server that holds the code. And the client holds the information about the gui which is actually needed to display things.
Right-clicking ought to offer both methods - lua-interface on_rightclick(..) and formspec if given.
A list of my mods can be found
here.