-
Notifications
You must be signed in to change notification settings - Fork 17
Menu GUIs
Caution
Menu GUIs are currently experimental.
They must be enabled using the menu guis experiment.
That is, you must add using menu guis to the top of your script.
Important
Menu GUIs are available on Minecraft 1.21.1 and newer.
It is also not currently possible to change their name or size.
Menu GUIs, unlike normal GUIs, make use of real inventories. That means crafting tables can craft, furnaces can smelt, and anvils can rename.
They also must opened using a specific syntax.
Similar to how virtual inventories are created using a dedicated expression, menu type inventories are created using one as well (the menu inventory expression). The syntax is similar but has one primary difference: the inventory must be bound to a player, and it can only be displayed to that player.
%inventorytype% menu [with %-number% row[s]] [(named|with (name|title)) %-textcomponent%] bound to %player%
%inventorytype% menu [(named|with (name|title)) %-textcomponent%] with %-number% row[s] bound to %player%A common use case for using a real inventory would be to capture input from a player through an anvil. We create the inventory differently, but the rest of the process is the same:
using menu guis
command /getinput:
trigger:
create a gui with anvil inventory menu named "Enter Input" bound to player:
make gui slot 0 with barrier named "" # Far Left Slot
make gui 2 with air: # Output Slot, formatted with air to just run a click action
set {_input} to anvil text input of gui
close the player's inventory
send title "You Entered" with subtitle {_input} to playerUnfortunately, Menu GUIs cannot be opened using the typical Skript syntax.
Instead, they must be opened using a skript-gui specific show gui effect:
(open|show|display) [gui] %gui% (to|for) %players%In most cases, this will actually look the same as Skript's default syntax for opening inventories.
However, if your GUI is stored in a variable, you may need to include the gui keyword before the variable itself.
So, we can easily extend the input capture example:
using menu guis
command /getinput:
trigger:
create a gui with anvil inventory menu named "Enter Input" bound to player:
make gui slot 0 with barrier named "" # Far Left Slot
make gui 2 with air: # Output Slot, formatted with air to just run a click action
set {_input} to anvil text input of gui
close the player's inventory
send title "You Entered" with subtitle {_input} to player
show the last created gui to the playerThen, in-game, it's as simple as ever: