#Whats wrong with this function

1 messages · Page 1 of 1 (latest)

gray crystal
#

function crops(t: text):
loop {%{_t}%.break::}:
add index of loop-value to {_top::
}
set {_s} to "%size of {_top::}%" parsed as integer
#set {_st} to 1
loop {_s} times:
set {_1} to {_top::%{_s}%}
set {_2} to {_top::%{_s} - 1%}
if {%{_t}%.break::%{_1}%} > {%{_t}%.break::%{_2}%}:
set {_top::%{_s} - 1%} to {_1}
set {_top::%{_s}%} to {_2}
remove 1 from {_s}
loop {_top::
}:
set {%{_t}%.position::*} to index of loop-value

#

a dev made it for me and he cant test it and it doesnt work

winter river
#

please format it properly
```vb

code here

```

#

` is the top left of american keyboards

#

same key as tilde ~

gray crystal
#
function crops(t: text):
    loop {%{_t}%.break::}:
        add index of loop-value to {_top::}
    set {_s} to "%size of {_top::}%" parsed as integer
    #set {_st} to 1
    loop {_s} times:
        set {_1} to {_top::%{_s}%}
        set {_2} to {_top::%{_s} - 1%}
        if {%{_t}%.break::%{_1}%} > {%{_t}%.break::%{_2}%}:
            set {_top::%{_s} - 1%} to {_1}
            set {_top::%{_s}%} to {_2}
        remove 1 from {_s}
    loop {_top::}:
        set {%{_t}%.position::*} to index of loop-value
#

i copied your symbols

winter river
#

you should re-copy your code

#

you copied it from discord which removed *

gray crystal
#

oh kk

#
function crops(t: text):
    loop {%{_t}%.break::*}:
        add index of loop-value to {_top::*}
    set {_s} to "%size of {_top::*}%" parsed as integer
    #set {_st} to 1
    loop {_s} times:
        set {_1} to {_top::%{_s}%}
        set {_2} to {_top::%{_s} - 1%}
        if {%{_t}%.break::%{_1}%} > {%{_t}%.break::%{_2}%}:
            set {_top::%{_s} - 1%} to {_1}
            set {_top::%{_s}%} to {_2}
        remove 1 from {_s}
    loop {_top::*}:
        set {%{_t}%.position::*} to index of loop-value
#

here

#

oh i think i found an error

#

nvm

winter river
#

so what exactly is this meant to do

gray crystal
#

a leaderboard

scarlet crow
#

Lol

#

Hi sovde btw

gray crystal
#

it should check the amount of broken crops from every player and say which position u are

winter river
#

i assume %{_t}%.break is a list of player uuids and break counts?

gray crystal
#

yep

scarlet crow
#

What about leaderbroards

winter river
#

then just use sorted indices of {%{_t}%.break::*}

gray crystal
#

could u send the skript here

winter river
#

eg:

loop sorted indices of {%{_t}%.break::*}:
    broadcast "%loop-index% - %loop-value% with {%{_t}%.break::%loop-value%} blocks broken"
gray crystal
#

instead of loop {%{_t}%.break::*}:

#

right?

winter river
#

instead of the whole function

gray crystal
#

huh

winter river
#

assuming {%{_t}%.position::*} is a list of players in order of breaks:

set {%{_t}%.position::*} to sorted indices of {%{_t}%.break::*}
gray crystal
#

it shouldnt be broadcasted also it should be a lore of an item

winter river
gray crystal
#

i am a bit confused bec i didnt make this skript could u send me a whole working version if thats ok

winter river
#

sorted indices just gives you the list of players in order

gray crystal
#

sadge

winter river
gray crystal
#

ill try stuff out

#

@winter river i got an error "There is no loop that matches 'loop-index' "

winter river
#

oh yeah that would happen

#

you can either

set {_l::*} to sorted indices of {%{_t}%.break::*}
loop {_l::*}:
    broadcast "%loop-index% - %loop-value% with {%{_t}%.break::%loop-value%} blocks broken"

or

loop sorted indices of {%{_t}%.break::*}:
    add 1 to {_i}
    broadcast "%{_i}% - %loop-value% with {%{_t}%.break::%loop-value%} blocks broken"
gray crystal
#

ill try both