Pagination

Learn about Pagination in Skript

Pagination is a concept that allows you to make paginated GUIs. This is a concept both for Minecraft programmers and programmers outside of Minecraft. Here you can learn how to successfully use it in Skript.

Take a look at an example.

function pagination(p: player, pg: number=1, v: string):
set {_players::*} to all players where [{_v} = "players"]
create a gui with virtual chest with 6 rows named "&8Pagination (%{_pg}%)":
{_pg} > 1:
make gui slot 45 with arrow named "&c&lBACK" with lore "&7Click to view page &b%{_pg} - 1%":
pagination({_p}, {_pg} - 1, {_v})
size of {_players::*} > {_pg}*44:
make gui slot 53 with arrow named "&b&lNEXT PAGE" with lore "&7Click to view page &b%{_pg} + 1%":
pagination({_p}, {_pg} + 1, {_v})
loop {_players::*}:
(loop-index parsed as integer) > ({_pg} - 1)*45:
(loop-index parsed as integer) < ({_pg}*45)+1:
set {_n} to ({_n} ? -1) + 1
make gui slot {_n} with skull of ("%loop-value%" parsed as offlineplayer) named "&b%loop-value%" with lore "&7Online"
open last gui to {_p}
‚Äč
command /players:
trigger:
pagination(player, 1, "players")

The example above creates a paginated GUI of all the players on your server. To see the pages, you'll need more players than slots on the first page. You can test this by adding fake values to the variable.