Loop Variable Problem

  • 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.

TenToTu Sho

Member
Dec 30, 2019
20
2
3
23
hi, im making a code, but i have this following problem:
Code:
command /test123:
    permission: admin.test
    trigger:
        loop {pvp.elo.*}:
            loop-value is greater than 1999
            set {seasonglory} to loop-value - 2000
            set {seasonglory} to {seasonglory} / 2
            if {seasonglory} is not an integer:
                remove 0.5 from {seasonglory}
            remove {seasonglory} from loop-value
            add {seasonglory} to {pvp.glory.%loop-player%}  # i want to add seasonglory to {pvp.glory.%whatever the "*" in "loop {pvp.elo.*}" is%}
 
  • Like
Reactions: jaksia
hi, im making a code, but i have this following problem:
Code:
command /test123:
    permission: admin.test
    trigger:
        loop {pvp.elo.*}:
            loop-value is greater than 1999
            set {seasonglory} to loop-value - 2000
            set {seasonglory} to {seasonglory} / 2
            if {seasonglory} is not an integer:
                remove 0.5 from {seasonglory}
            remove {seasonglory} from loop-value
            add {seasonglory} to {pvp.glory.%loop-player%}  # i want to add seasonglory to {pvp.glory.%whatever the "*" in "loop {pvp.elo.*}" is%}

Well nice problem whould have been usefull to see errors and get more info about what it should do and doesn't do.
 
I said it in the code, after the last line, after the #

okay but i still can't see what its supposed to do and what its not dooing? + any errors console & reload
[doublepost=1584371224,1584370138][/doublepost]Okay nvm i looked at it next time pls add more info bc now i need to guess what its supposed to do.

First of all:

Code:
loop {pvp.elo.*}:

U can't loop {pvp.elo.*}
{pvp.elo.*} is just a normal variable named "pvp.elo.*"
so "pvp.elo.*" could be the same as "pvp-elo-*"

What u are looking for are list variables.

List variables are defined like this:
Code:
{pvp.elo::*}

The use of :: defines that the variable is a list.

the * means all indexes of list.

A list can have indexes and values.

Code:
Index -> Value
1 -> Player
2 -> Location
Test -> Location

So how do u set a list variables index and value:

Code:
set {pvp.elo::1} to Player
set {pvp.elo::2} to Location of player
set {pvp.elo::test} to Location of player

so now if i would loop {pvp.elo::*}

Code:
loop {pvp.elo::*}:
    send "%loop-index% -> %loop-value%"

This code would send in chat:

Code:
1 -> Lego_freak1999
2 -> 23.5, 22.3, 23.7 ETC
Test -> 23.5, 22.3, 23.7 ETC

But ofc ur not demanded to use the index as u did u can also add and remove from a list like this:

Code:
add Player to {pvp.elo::*}
add Location of player to {pvp.elo::*}
add Location of player to {pvp.elo::*}

remove Player from {pvp.elo::*}
remove Location of player from {pvp.elo::*}
remove Location of player from {pvp.elo::*}

This will do the same as above with set except:

The difference is that u now don't get to set the indexes. Skript will auto fill the index now with numbers so the first one u add will be 1, second 2, third 3 etc.

Also u see that i added the same location twice to the list. Wenn u use the remove effect it will remove only 1 of the 2 locations so u still have to do the remove effect multiple times.

Efficiency tip:

If u gonna work with large variable lists its better to use set than add where possible. everytime u using a add to a list skript will check the entirelist. For set it doesn't have to do that.
 
  • Like
Reactions: Jairo Echevarria
Status
Not open for further replies.