Skip to content

1. Creating your first GUI

APickledWalrus edited this page Aug 11, 2022 · 4 revisions

Creating a new GUI with skript-gui is simple.

Creating a New GUI

The pattern to create a new GUI:

create [a] [new] gui [[with id] %-string%] with %inventory% [(and|with) ([re]move[e]able|stealable) items] [(and|with) shape %-strings%]

Using Virtual Inventories

When creating a GUI, you need to provide an inventory. This is where using the Virtual Inventory expression is useful.

Virtual Inventory Patterns:

virtual %inventorytype% [with size %number%] [(named|with (name|title)) %string%]
virtual %inventorytype% [with %number% row[s]] [(named|with (name|title)) %string%]
virtual %inventorytype% [(named|with (name|title)) %string%] with size %number%
virtual %inventorytype% [(named|with (name|title)) %string%] with %number% row[s]

TIP! Not sure what an inventory type looks like? View it here: https://skriptlang.github.io/Skript/classes.html#inventorytype

Now we can put together a basic GUI.

command /opengui:
  trigger:
    create a gui with virtual chest inventory

Customization Options

However, there are many more customization options for the GUI and Virtual Inventory Expression.

Name - The title displayed in the top-left of the inventory
Example - virtual chest inventory named "My EPIC GUI!"

Size - The number of rows in a GUI
Example - virtual chest inventory with 3 rows

The two above options can be combined in several ways. One way is:

virtual chest with 3 rows named "My EPIC GUI!"

All the ways to write it are shown in the patterns listed above.

Stealable Items - With this, you can specific whether items from this GUI can be taken by players.
Example - create a gui with virtual chest inventory and stealable items
Note: By default, items can't be taken from a GUI.

Shape - Shape allows you to customize the layout of a GUI
Example - create a gui with virtual chest inventory and shape "xxxxxxxxx", "x-------x", and "xxxxxxxxx"
This would create a GUI that has an 'x' border.
When setting the slots of a GUI, you could set the slot 'x' of the GUI, and all of those slots would be set,
creating a border around the GUI.

Now, we can create more advanced GUIs. Look at the following, for example:

create a gui with virtual chest inventory with 3 rows named "My EPIC GUI!" and shape "xxxxxxxxx", "x-------x", and "xxxxxxxxx"

Here's how that would look in-game (with the 'x' part of the shape set):

create a gui with virtual chest inventory with 3 rows named "My EPIC GUI!" and shape "xxxxxxxxx", "x-------x", and "xxxxxxxxx"

Opening a GUI

A GUI can be opened like any other inventory through Skript.

Script Example: create a gui with virtual chest open the last gui to player


### Accessing a Created GUI

To use the GUI you just created, you can use the Last GUI Expression. Pattern:
```yaml
[the] (last[ly] [(created|edited)]|(created|edited)) gui

That sums up creating and opening a GUI! Be sure to check out the next pages on how to edit and add items to your GUI.