1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved How to detect last in a list variable?

Discussion in 'Skript' started by CreeperOverLord7, Jan 19, 2018.

Thread Status:
Not open for further replies.
  1. CreeperOverLord7

    Joined:
    Jan 19, 2018
    Messages:
    17
    Likes Received:
    1
    Basically what the title says, is there a way to detect the last number in a list variable? So for example, I have "Line 1" stored in {example::1} and "Line 2" stored in {example::2}, and so on up to 10. Is there a way to make Skript detect the max is 10 and make it use the value somewhere? Like, for example, I want Skript to delete the latest variable in the list, so I'd do "delete {example::10}", but what if I don't know what is the latest? Is there a way to do this?

     
  2. Best Answer:
    Post #4 by ChisleLP, Jan 19, 2018
  3. Syst3ms

    Addon Developer

    Joined:
    Jan 24, 2017
    Messages:
    191
    Likes Received:
    22
    Try "last element of {list::*}"
     
  4. CreeperOverLord7

    Joined:
    Jan 19, 2018
    Messages:
    17
    Likes Received:
    1
    Doesn't work, it says "Cannot clear/delete last element of {warnings.%arg 1%::*}" when I do /sk reload scripts. ;-;
     
  5. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    Code (Skript):
    1. set {_s} to size of {_list::*}
    2. send "%{_list::%{_s}%}%"
    3. send "NOT TESTED: %{_list::%size of {_list::*}%}%"
     
    JX_Snack likes this.
  6. CreeperOverLord7

    Joined:
    Jan 19, 2018
    Messages:
    17
    Likes Received:
    1
    Thanks! It worked! :emoji_slight_smile:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...