Showing gui to player after right clicking on block

mrkubax10
New member
 
Posts: 1
Joined: Sat Dec 14, 2019 11:06
GitHub: KubaVPL10
IRC: mrkubax10
In-game: mrkubax10

Showing gui to player after right clicking on block

by mrkubax10 » Sat Dec 14, 2019 11:17

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
GreenDimond
Member
 
Posts: 1295
Joined: Wed Oct 28, 2015 01:26
Location: SCP-3008
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Showing gui to player after right clicking on block

by GreenDimond » Sat Dec 28, 2019 06:55

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.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenDimond#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.
 


Return to Problems



Who is online

Users browsing this forum: No registered users and 6 guests