[Solved] How to get position in player_receive_fields?

Post Reply
User avatar
v-rob
Developer
Posts: 971
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

[Solved] How to get position in player_receive_fields?

by v-rob » Post

So, I have a node with a formspec, and I have a register_on_player_receive_fields function for it. The problem is that I need the position of the node so that I can set metadata in it. I've looked at multiple mods, but the way they do it seems to vary, and none of them seem to work properly in my mod.

Another thing: What's the best way to reshow the formspec in the register_on_player_receive_fields function? I need to change some of the elements in the formspec in that function. I'm using minetest.show_formspec, but I think that there's probably a better way to do it.

Thanks.
Last edited by v-rob on Sun Jun 10, 2018 20:25, edited 1 time in total.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: How to get position in register_on_player_receive_fields

by Krock » Post

When you need the node position, then overwrite the node's `on_rightclick` callback so you can store the node position in a table and send the formspec to the clicker. This way you can use the clicker name in the `register_on_player_receive_fields` callback to get the node position from the table. It's also the method which the default chests use.

`minetest.show_formspec` is the only way to update or show a new formspec when a callback occurs.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
v-rob
Developer
Posts: 971
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: [Solved] How to get position in player_receive_fields?

by v-rob » Post

Thanks very much. I never would have figured that out on my own.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests