Showing gui to player after right clicking on block

Post Reply
User avatar
mrkubax10
Member
Posts: 16
Joined: Sat Dec 14, 2019 11:06
GitHub: mrkubax10
IRC: mrkubax10
In-game: mrkubax10

Showing gui to player after right clicking on block

by mrkubax10 » Post

Hello!
I'm creating a mod for minetest 0.4.16 and I'm trying to create gui which will be showed to player after right clicking block.
I want the gui to contain slot in which we can put item and in other slot other item will be added.

Sorry for my english but it isn't my native language.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: Showing gui to player after right clicking on block

by GreenXenith » Post

A bit late, but I figured an answer would be nice for future's sake.
mrkubax10 wrote:I'm creating a mod for minetest 0.4.16
If you insist on using 0.4.x, I would suggest upgrading to 0.4.17.1. Otherwise, you may want to upgrade to 5.1.0 -- lots of new fun API features have been added!
I'm trying to create gui which will be showed to player after right clicking block.
Assuming you know how to make a formspec (gui), you can show it to the player via on_rightclick in the node definition of the block you wish to show it from. Something akin to

Code: Select all

on_rightclick = function(pos, node, clicker)
    minetest.show_formspec(clicker:get_player_name(), "my_awesome_form", "label[0,0,This is a formspec!]")
end,
Useful guide to formspecs here.
I want the gui to contain slot in which we can put item and in other slot other item will be added.
This will require a node metadata inventory and for your formspec to be a node meta formspec.

Note that the links to the API I used were for 0.4.17.1, while the modding book contains content pertaining to version >=5.0.0.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

Post Reply

Who is online

Users browsing this forum: SkyBuilder1717 and 8 guests