How can I run a function when a node is right clicked?

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

How can I run a function when a node is right clicked?

by Neuromancer » Thu Dec 20, 2012 02:19

Rather than wiring up on_punchnode which is for left click, what do I do for right clicked?
Last edited by Neuromancer on Thu Dec 20, 2012 02:35, edited 1 time in total.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Thu Dec 20, 2012 05:40

on_use, isn't it?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu Dec 20, 2012 16:27

There isnt such function in the API.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron