Skript: Many issues with list variables after upgrading to 2.2-dev26d

Created on 13 Apr 2017  路  7Comments  路  Source: SkriptLang/Skript

There is something buggy with looping list variables now:


command /testy:
    trigger:
        add "player1" to {_score::*}
        add "player2" to {_score::*}
        add "player3" to {_score::*}
        set {_score::player1::noob} to "yes"
        set {_score::player2::noob} to "yes"
        set {_score::player3::noob} to "yes"
        loop {_score::*}:
            message "%loop-index%: %loop-value%"
        # Result:
        # 1: player1
        # 2: player1player2
        # 3: player1player2player3

The expected output should be:

    # Result:
    # 1: player1
    # 2: player2
    # 3: player3

This and many other of my scripts are working fine with older version of skript.

bug

Most helpful comment

Apparently this was caused by me doing too "clever" optimizations by merging chat components together. Fixed in next release.

All 7 comments

Confirmed.

I wonder, what is result when you use {_score::3}? Still same and wrong?

Will test now.

No, actually... it's strange. Sending them individually, but any means of looping and sending it via a loop-value or {_list;:%loop-index%} has the above issue. With the following code:

on script load:
    add "player1" to {_score::*}
    add "player2" to {_score::*}
    add "player3" to {_score::*}

    send "%{_score::1}%" to all players
    send "%{_score::2}%" to all players
    send "%{_score::3}%" to all players

    loop {_score::*}:
        send "%loop-index%: %{_score::%loop-index%}%" to all players

    loop size of {_score::*} times:
        send "%loop-value%: %{_score::%loop-value%}%" to all players

I get this result.

Of note: I had to use send "<message>" to all players because I initially tried using broadcast and it actually fixed the issue. That being the case, I assume it has something to do with the issues being caused by the JSON stuff.

The actual issue is that you are not allowed to mix variables and normal text in a string. send "%{_var}% or send "%{_var}%%{_var}%" work just fine, while send "var: %{_var}% does not work.

Some example code to test it:

command /t:
    trigger:
        set {_var} to true
        loop 5 times:
            send "%{_var}%"
            send "V: %{_var}%"

This is definitely caused by the json stuff.

Hmm... This is very interesting, since I definitely triee JSON chat with variables+text. Will need to test it myself.

Apparently this was caused by me doing too "clever" optimizations by merging chat components together. Fixed in next release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Snow-Pyon picture Snow-Pyon  路  20Comments

iOshawott picture iOshawott  路  22Comments

bensku picture bensku  路  31Comments

RichVillage picture RichVillage  路  26Comments

StealWonders picture StealWonders  路  21Comments