I currently only have a few, but more will be coming soon.
Paginated GUI
Today, I embarked on a project to create a very manageable and easy-to-use GUI for both players and server administrators. After fiddling around with a pagination system for my tag GUI, I finally got it working by using a system similar to grabbing pagination with PHP.
I've explained each part of the script pretty well using comments, hoping that you'll be able to edit and fill in the rest yourself.
Typing GUI
With the typing GUI, you can allow your players to type uppercase and lowercase letters, along with spaces, in a GUI and have it outputted via a message. You can integrate this into other scripts that might require some form of typing (clan names, etc.) where you might not want to use chat.
...Possibly a replacement for the anvil GUI?
Armor Stand Editor
As suggested by one of the users on the official skUnity Discord server, I have made a very simple armor stand editor. I am calling such a snippet simple because it still requires basic knowledge of NBT and the values they support. For example, for true and false statements, you would have to input 1 or 0. However, for rotations, you don't need to add an f after the degree, as it is automatically entered.
Paginated GUI
Today, I embarked on a project to create a very manageable and easy-to-use GUI for both players and server administrators. After fiddling around with a pagination system for my tag GUI, I finally got it working by using a system similar to grabbing pagination with PHP.
I've explained each part of the script pretty well using comments, hoping that you'll be able to edit and fill in the rest yourself.
code_language.skript:
command /gui [<integer=1>]:
trigger:
set {_list::*} to integers from 1 to 215
# This is just an example of a list variable that would be used.
# Make sure to change the other parts of the script where this variable is used and not just this list variable.
set {_page::rows} to 3
# This is the amount of rows in the GUI.
set {_page::max} to arg 1 * (({_page::rows} - 1) * 9)
set {_page::min} to (arg 1 - 1) * (({_page::rows} - 1) * 9)
set {_page::posts} to 0
set {_page::count} to 0
set {_page::number} to arg 1
# These specify the amount of items that should be displayed on each page.
set {_pages} to size of {_list::*} / (({_page::rows} - 1) * 9)
set {_pages} to "%{_pages}%"
set {_pages::*} to {_pages} split at "."
# The only reason I have to set a variable to itself is because Skript won't allow me to do this any other way.
set {_page::total} to {_pages::1}
if {_pages::2} is set:
set {_page::total} to {_page::total} parsed as an integer
add 1 to {_page::total}
# This will grab the total amount of pages.
if inventory name of player's current inventory does not contain "&8GUI | ":
open chest with {_page::rows} rows named "&8GUI | %{_page::number}%/%{_page::total}%" to player
# Only open a new chest if the player isn't already in the GUI.
else:
loop ({_page::rows} * 9) times:
set slot (loop-number - 1) of player's current inventory to air
set inventory name of player's current inventory to "&8GUI | %{_page::number}%/%{_page::total}%"
# Reset the GUI if the player is already in it.
if {_page::number} is greater than 1:
set slot (({_page::rows} - 1) * 9) of player's current inventory to piston named "&dPrevious Page"
# Display a previous page button only if the user is not on the first page.
loop {_list::*}:
if {_page::count} is less than {_page::max}:
if {_page::count} is greater than or equal to {_page::min}:
# Only display an item if certain page specifications are met.
set slot {_page::posts} of player's current inventory to stone named "&b%loop-value%"
add 1 to {_page::posts}
add 1 to {_page::count}
if {_page::number} is less than {_page::total}:
set slot ({_page::rows} * 9 - 1) of player's current inventory to piston named "&dNext Page"
# Display a next page button if the current page is not the last page.
on inventory click:
if inventory name of player's current inventory contains "&8GUI | ":
cancel the event
set {_page::rows} to 3
# This is the amount of rows in the GUI.
set {_page} to "%inventory name of player's current inventory%"
replace all "&8GUI | " in {_page} with ""
set {_pages::*} to {_page} split at "/"
# Grab the page that the player is currently on.
if clicked slot is (({_page::rows} - 1) * 9):
if clicked item name is "&dPrevious Page":
if {_pages::1} parsed as an integer is greater than 1:
execute player command "/gui %{_pages::1} parsed as an integer - 1%"
# Open the previous page to the user if they are not already on it.
else:
close inventory of player
send "You are already on the first page."
else if clicked slot is ({_page::rows} * 9 - 1):
if clicked item name is "&dNext Page":
execute player command "/gui %{_pages::1} parsed as an integer + 1%"
# Open the next page to the user.
Typing GUI
With the typing GUI, you can allow your players to type uppercase and lowercase letters, along with spaces, in a GUI and have it outputted via a message. You can integrate this into other scripts that might require some form of typing (clan names, etc.) where you might not want to use chat.
...Possibly a replacement for the anvil GUI?
code_language.skript:
command /type:
trigger:
open chest with 5 rows named "&8Text: _" to player
# Open a chest to the player with enough rows to handle the alphabet and numbers, along with a space.
set slot 41 of player's current inventory to green stained glass pane named "&aDone"
set slot 39 of player's current inventory to red stained glass pane named "&cCancel"
set slot 35 of player's current inventory to white stained glass pane named "&7Space"
set slot 44 of player's current inventory to gray stained glass pane named "&9Backspace"
set slot 36 of player's current inventory to gray stained glass pane named "&9Uppercase"
# Adds a done and cancel button, along with the space character and uppercase letters.
set {_slot} to 36
loop 9 times:
if {_slot} is not 39 or 44 or 41 or 36:
set slot {_slot} of player's current inventory to black stained glass pane named "&8"
add 1 to {_slot}
# Set the empty slots of the bottom row to black stained glass pane.
set {_letters::*} to split "abcdefghijklmnopqrstuvwxyz123456789" at ""
set {_slot} to 0
loop {_letters::*}:
if {_slot} is greater than 34:
stop
set slot {_slot} of player's current inventory to name tag named "&7%loop-value%"
add 1 to {_slot}
# Loop through the letters of the alphabet and add them in to the GUI.
on inventory click:
if inventory name of player's current inventory contains "&8Text: ":
cancel the event
set {_text} to "%inventory name of player's current inventory%"
replace all "&8Text: " and "_" in {_text} with ""
# Grab the name of the GUI (their text).
if clicked slot is less than 36:
if length of {_text} is greater than 64:
send "You cannot add anymore letters to your text."
# Set the maximum number of letters to 64, as I am not sure what the maximum GUI title length is.
else:
set {_name} to "%{_text}%%clicked item name%_"
replace all "&7" in {_name} with ""
# Grab the letter clicked.
if clicked slot is 35:
set {_name} to "%{_text}% _"
# Set the letter to a space if the space block is clicked.
if length of {_text} is greater than 62:
replace all "_" in {_name} with ""
# Remove the _ from the title to inform users that they are no longer able to add letters.
set inventory name of player's current inventory to "&8Text: %{_name}%"
# Set the name of the inventory to the new text.
else if clicked slot is 39:
close inventory of player
send "Your text has been removed from memory."
else if clicked slot is 41:
close inventory of player
if {_text} is not "":
send "Your text is: %{_text}%"
# Send the text to the user if there is any.
else:
send "No text had been added."
else if clicked slot is 44:
if length of {_text} is greater than 1:
set {_name} to subtext of "%{_text}%" from 1 to (length of {_text} - 1)
else:
set {_name} to ""
# Grab the text and remove the last letter, or set the text to empty if there is no text after removal.
set inventory name of player's current inventory to "&8Text: %{_name}%_"
# Set the name of the inventory to the new text.
else if clicked slot is 36:
if clicked item name is "&9Uppercase":
set {_letters::*} to split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" at ""
set {_slot} to 0
loop {_letters::*}:
if {_slot} is greater than 34:
stop
set slot {_slot} of player's current inventory to name tag named "&7%loop-value%"
add 1 to {_slot}
set slot 36 of player's current inventory to gray stained glass pane named "&9Lowercase"
# Set the letters to uppercase and the case button to lowercase.
else if clicked item name is "&9Lowercase":
set {_letters::*} to split "abcdefghijklmnopqrstuvwxyz" at ""
set {_slot} to 0
loop {_letters::*}:
if {_slot} is greater than 34:
stop
set slot {_slot} of player's current inventory to name tag named "&7%loop-value%"
add 1 to {_slot}
set slot 36 of player's current inventory to gray stained glass pane named "&9Uppercase"
# Set the letters to lowercase and the case button back to uppercase.
Armor Stand Editor
As suggested by one of the users on the official skUnity Discord server, I have made a very simple armor stand editor. I am calling such a snippet simple because it still requires basic knowledge of NBT and the values they support. For example, for true and false statements, you would have to input 1 or 0. However, for rotations, you don't need to add an f after the degree, as it is automatically entered.
code_language.skript:
command /editas [<text>] [<text>] [<text>] [<text>] [<text>]:
trigger:
if "%targeted entity%" is "armor stand":
# Force the player to be looking at an armor stand.
if arg 1 is "NoGravity" or "ShowArms" or "Invisible" or "Small" or "NoBasePlate":
# Check if the first value is a piece of true/false NBT.
if arg 2 is "1" or "0":
# Force the user to input either 1 (true) or 0 (false).
add "{%arg 1%:%arg 2%}" to nbt of targeted entity
send "An NBT value of {%arg 1%:%arg 2%} has been added to the targeted armor stand."
# Add the NBT to the armor stand.
stop
send "You must specify 1 or 0. (true/false)"
else if arg 1 is "Pose":
if arg 2 is "Head" or "Body" or "LeftArm" or "RightArm" or "LeftLeg" or "RightLeg":
# Check if the second value is a correct part of the armor stand.
if "%arg 3%%arg 4%%arg 5%" does not contain "<none>":
# Force the player to enter integers for the rotations.
add "{%arg 1%:{%arg 2%:[%arg 3%f,%arg 4%f,%arg 5%f]}}" to nbt of targeted entity
send "An NBT value of {%arg 1%:{%arg 2%:[%arg 3%f,%arg 4%f,%arg 5%f]}} has been added to the targeted armor stand."
# Add the NBT to the armor stand.
stop
send "You must specify three rotations."
stop
send "You must specify a part of the armor stand to modify."
else if arg 1 is "ArmorItems":
if "%arg 2%%arg 3%%arg 4%%arg 5%" does not contain "<none>":
# Check if all of the arguments are filled in.
set {_armor::head} to ""
set {_armor::chest} to ""
set {_armor::legs} to ""
set {_armor::boots} to ""
# Set the variables to empty, so that they won't return <none> if they aren't changed.
if arg 2 is not "none":
set {_armor::head} to "Count:1,id:""%arg 2%"""
set targeted entity's helmet to (arg 2 parsed as an item)
# Change the NBT if the value isn't none.
if arg 3 is not "none":
set {_armor::chest} to "Count:1,id:""%arg 3%"""
set targeted entity's chestplate to (arg 3 parsed as an item)
# Change the NBT if the value isn't none.
if arg 4 is not "none":
set {_armor::legs} to "Count:1,id:""%arg 4%"""
set targeted entity's leggings to (arg 4 parsed as an item)
# Change the NBT if the value isn't none.
if arg 5 is not "none":
set {_armor::boots} to "Count:1,id:""%arg 5%"""
set targeted entity's boots to (arg 5 parsed as an item)
# Change the NBT if the value isn't none.
send "An NBT value of {ArmorItems:[{%{_armor::boots}%}, {%{_armor::legs}%}, {%{_armor::chest}%}, {%{_armor::head}%}]} has been added to the targeted armor stand."
send "&cskStuff is currently having problems with armor NBT, which is why we are using effects from Skript instead of adding NBT."
# Add the NBT to the armor stand.
stop
send "You must specify an item for each slot, or none."
else:
send "You must specify an NBT value to alter."
stop
send "You must be looking at an armor stand to edit it."
Last edited: