Help with a list

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Feb 24, 2017
191
7
0
23
foroendertheth.foroactivo.com
Ok the code works but if I have for example 30 warps how I make a list that show me first 10 then like I use /warp list 2 and show me 10 more
code_language.skript:
Loop {warp list::*}:
    Add 1 to {_number}
    Message "%{_number}%. %loop-value%"
    Wait a tick
 
code_language.skript:
command /warplist [<number=0>]:
    trigger:
        set {_s} to arg-1
        set {_w::*} to {warp list::*}
        set {_i} to 0 + {_s} * 10
        message "&2%{_s} * 10 + 1% - %{_s} * 10 + 10%"
        loop 10 times:
            add 1 to {_i}
            if {_w::%{_i}%} is not set:
                message "%{_i}%: &cnot set"
            else:
                message "%{_i}%: %{_w::%{_i}%}%"
 
code_language.skript:
command /warplist [<number=0>]:
    trigger:
        set {_s} to arg-1
        set {_w::*} to {warp list::*}
        set {_i} to 0 + {_s} * 10
        message "&2%{_s} * 10 + 1% - %{_s} * 10 + 10%"
        loop 10 times:
            add 1 to {_i}
            if {_w::%{_i}%} is not set:
                message "%{_i}%: &cnot set"
            else:
                message "%{_i}%: %{_w::%{_i}%}%"
Can you explain this please ?
Because I don't know how that works and I want to learn
 
I hope these comments will make you understand it more:
code_language.skript:
command /warplist [<number=0>]:    # the '=0' part stands for if the argument isn't given, it will be set to 0
    trigger:
        set {_s} to arg-1        # I had to save the argument in a variable because else there would be a strange bug
        set {_w::*} to {warp list::*}        # just setting a shorter name for the list variable here
        set {_i} to {_s} * 10            # this variable is the starting point for the list: the first argument times 10
        message "&2%{_s} * 10 + 1% - %{_s} * 10 + 10%"            # messaging the range for which items from the list will be shown
        loop 10 times:        # looping 10 times, since you wanted 10 items per 'page'
            add 1 to {_i}        # add 1 to the variable 'i', which I set to the starting point before
            if {_w::%{_i}%} is not set:        # checking if the item from the loop which we are currently at is set
                message "%{_i}%: &cnot set"            # if it's not set, message our current number (i) and 'not set' in light red
            else:
                message "%{_i}%: %{_w::%{_i}%}%"    # if it is set, message our current number (i) and the value from the list ({[list-name]::[list-index]}, so in this case: {_w::%{_i}%}, _w is the list variable and {_i} the index)
 
An easier way to do it would be using TuSKe and its page expression:

code_language.skript:
command /warp <text="list"> <page:number=1>:
  trigger:
   
    if argument-1 is "list":

      set {_warps::*} to page abs(argument-2) of {warp list::*} with 10 lines # using the absolute value function just in-case the user inputs a negative integer
      set {_last-page} to rounded up (size of {warp list::*}/10)

      if {_warps::*} is set:
        send "<orange>Showing page <light red>%abs(argument-2)%/%{_last-page}%"
      else:
        send "<red>There are no available warps!"

      loop {_warps::*}:
        send "<yellow>%loop-index%. <light green><command:/warp %loop-value%>%loop-value%" # clicking on the warp name will teleport the player, just remove the command chat code if you aren't using bensku's fork dev30+
 
An easier way to do it would be using TuSKe and its page expression:
code_language.skript:
#warps
command /warp [<text>] [<text>]:
    aliases: /warps
    trigger:
        if arg 1 is "create" or "crear":
            if arg 2 is set:
                if {survival:warp::%arg 2%} is set:
                    message "{@logo}Ya ese warp existe"
                else:
                    set {survival:warp::%arg 2%} to the player's location
                    add arg 2 to {warps::*}
                    message "{@logo}Warp ""%arg 2%"" creado"
            else:
                message "{@logo}/Warp crear (<nombre>)"
        else if arg 1 is "remove" or "delete" or "borrar" or "remover":
            if arg 2 is set:
                if {survival:warp::%arg 2%} is set:
                    delete {survival:warp::%arg 2%}
                    remove arg 2 from {warps::*}
                    message "{@logo}Warp ""%arg 2%"" Borrado"
                else:
                    message "{@logo}Ese warp no existe"
            else:
                message "{@logo}/Warp remove (<nombre>)"
        else if arg 1 is "list" or "lista":
            loop {warps::*}:
                add 1 to {_number}
                message "&e[&cWarps&e]&9%{_number}%. &a%loop-value%"
                wait 0.5 second
        else if arg 1 is "help" or "ayuda":
            message "&eWarps"
            message "&9/Warps crear (<nombre>)"
            message "&9/Warps borrar (<nombre>)"
            message "&9/Warps lista"
            message "&9/Warps (<warp>)"
        else:
            if arg 1 is set:
                if {survival:warp::%arg 1%} is set:
                    teleport the player to {survival:warp::%arg 1%}
                    message "{@logo}Teleportado a Warp ""%arg 1%"""
                else:
                    message "{@logo}Warp ""%arg 1%"" no existe"
                    message "{@logo}Usa /Warp lista"
            else:
                message "{@logo}/Warp ayuda"
I does not understand what do you do there im not so good with skript. I am now starting to learn loops and this variables {example::*}
 
Status
Not open for further replies.