Loop value or index help

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

xMistical

Member
Aug 2, 2018
24
0
0
27
Hi, i would like to know how to obtain the value 2 of a variable in the bone list
for example
{test::*}
add "test1" to {test :: *}
add "test2" to {test :: *}
add "test3" to {test :: *}
add "test4" to {test :: *}
I need to know how to send the player only the value of "test2", because when I use "% loop-value-2%" «it gives me loop errors matches
with "% loop-value%" it sends me all the values saved in the list {test :: *}
how can I get and send only the second value
 
with the spaces?
code_language.skript:
every 10 seconds:
    set {_nodos::*} to skutil yaml nodes with keys "Anuncio" from file "plugins/Anuncios/config.yml"
    loop {_nodos::*}:
        # Reading a value
        set {_anuncio::%loop-value%} to skutil yaml value "Anuncio.%loop-value%" from file "plugins/Anuncios/config.yml"
        set {_last} to size of {_anuncio::*}
        set {_last} to {_last} parsed as number #I clarify that this is an example
        broadcast "%{_anuncio :: 1}%"
 
no that was reflective of your variable naming in the provided example.

in your actual code you set the index so it wont be a number. you can either put the actual index or just get the nth element
code_language.skript:
broadcast "%2nd element of {_anuncio::*}%"
broadcast "%{_anuncio::whatever the index actually is}%"
 
When I use broadcast "%{_ anuncio::1}%"
it appears to me as <none>
Then when I use %2nd element of {_anuncio::*}%
I get that this expression does not exist even with second element of, it only works when I use first element of read me the value 1 of the list.
 
why are you putting spaces in variables %2nd element of {_anuncio::*}%
 
It was the google translator that did that, but understand that I used part of the code I sent
 
broadcast "%2nd element of {_anuncio::*}%" works fine for me, what skript version are you using?
 
Why I get it as <none> with %{_anuncio::1}%
And I get error with %2nd element of {_anuncio::*}%
code_language.skript:
on load:
    if file "/plugins/Anuncios/config.yml" doesn't exist:
        create file "plugins/Anuncios/config.yml"
        set yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml" to "1"
        set yml value "Anuncio.Line|1" of file "plugins/Anuncios/config.yml" to "Random message 1"
        set yml value "Anuncio.Line|2" of file "plugins/Anuncios/config.yml" to "Random message 2"       
        set yml value "Anuncio.Line|3" of file "plugins/Anuncios/config.yml" to "Random message 3"
        set yml value "Anuncio.Line|4" of file "plugins/Anuncios/config.yml" to "Random message 4"       
        set yml value "Anuncio.Line|5" of file "plugins/Anuncios/config.yml" to "Random message 5"
every 10 minutes:
    set {_nodos::*} to skutil yaml nodes with keys "Anuncio" from file "plugins/Anuncios/config.yml"
    loop {_nodos::*}:
        # Reading a value
        set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"
        set {_anuncio::%loop-value%} to skutil yaml value "Anuncio.%loop-value%" from file "plugins/Anuncios/config.yml"
        set {_last} to size of {_anuncio::*}
        set {_last} to {_last} parsed as number
        set {_num} to {_num} parsed as number
        if {_num} is not {_last}:
            add 1 to {_num}
            broadcast "%{_anuncio::1}%"
            set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"
        if {_num} is {_last}:
            set {_num} to 1
            broadcast "%2nd element of {_anuncio::*}%"
            set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"
 
Last edited:
Why I get it as <none> with %{_anuncio::1}%
And I get error with %2nd element of {_anuncio::*}%
code_language.skript:
on load:
    if file "/plugins/Anuncios/config.yml" doesn't exist:
        create file "plugins/Anuncios/config.yml"
        set yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml" to "1"
        set yml value "Anuncio.Line|1" of file "plugins/Anuncios/config.yml" to "Random message 1"
        set yml value "Anuncio.Line|2" of file "plugins/Anuncios/config.yml" to "Random message 2"      
        set yml value "Anuncio.Line|3" of file "plugins/Anuncios/config.yml" to "Random message 3"
        set yml value "Anuncio.Line|4" of file "plugins/Anuncios/config.yml" to "Random message 4"      
        set yml value "Anuncio.Line|5" of file "plugins/Anuncios/config.yml" to "Random message 5"
every 10 minutes:
    set {_nodos::*} to skutil yaml nodes with keys "Anuncio" from file "plugins/Anuncios/config.yml"
    loop {_nodos::*}:
        # Reading a value
        set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"
        set {_anuncio::%loop-value%} to skutil yaml value "Anuncio.%loop-value%" from file "plugins/Anuncios/config.yml"
        set {_last} to size of {_anuncio::*}
        set {_last} to {_last} parsed as number
        set {_num} to {_num} parsed as number
        if {_num} is not {_last}:
            add 1 to {_num}
            broadcast "%{_anuncio::1}%"
            set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"
        if {_num} is {_last}:
            set {_num} to 1
            broadcast "%2nd element of {_anuncio::*}%"
            set {_num} to yml value "Anuncio|Estado" of file "plugins/Anuncios/config.yml"

You should also post the associated yaml file's content
 
{_anuncio::1} is none because like I said before the index won’t be 1 since you’re setting the index as loop-value. If you add something to a list then skript will automatically assign a number index

broadcasting the nth element should work idk why you’re getting errors from it, update skript
 
Status
Not open for further replies.