Jump to content

Infinite GUI pages

Recommended Posts

This script wasn't intended to be something that could be helpful to others, but seems like it will help a lot of you new learners.

The following example is how it works:

                            # {_page} is the page number
set {_end} to {_page} * 27  # {_end} is set to last slot in a 27 slot GUI
set {_start} to {_end} - 27 # {_start} is set to the first slot

loop {exampleList::*}:
    add 1 to {_pos}
    if {_pos} is between {_start} and {_end}:
        make next gui slot with loop-value

What are the variables?

{_page} is defined as the page number

{_start} is defined as the first slot in the GUI (slot 0)

{_end} is defined as the last slot in the GUI (slot 26)


The script in action:

command /gui [<integer>]:
        set {exampleList::*} to stone, grass block, granite, sand, paper, bone and chest
        set {_page} to 1
        set {_end} to {_page} * 27
        set {_start} to {_end} - 27
        if arg-1 is set:
            if arg-1 > 0:
                set {_page} to arg-1

        create a gui with virtual chest with 4 rows named "Example":
            loop {exampleList::*}:
                add 1 to {_pos}
                if {_pos} is between {_start} and {_end}:
                    make next gui slot with loop-value
            make gui slot 27 with paper named "<< Back":
                set {_back} to {_page} - 1
                if {_page} > 0:
                    make player execute "/gui %{_back}%"
            make gui slot 35 with paper named "Next >>":
                set {_next} to {_page} + 1
                make player execute "/gui %{_next}%"
        open last gui to player


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...