Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many issues with list variables after upgrading to 2.2-dev26d #499

Closed
bloggy opened this issue Apr 13, 2017 · 7 comments
Closed

Many issues with list variables after upgrading to 2.2-dev26d #499

bloggy opened this issue Apr 13, 2017 · 7 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.

Comments

@bloggy
Copy link

bloggy commented Apr 13, 2017

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.

@TheBentoBox
Copy link
Member

Confirmed.

@TheBentoBox TheBentoBox added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Apr 14, 2017
@bensku
Copy link
Member

bensku commented Apr 14, 2017

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

@TheBentoBox
Copy link
Member

Will test now.

@TheBentoBox
Copy link
Member

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.

@bi0qaw
Copy link
Contributor

bi0qaw commented Apr 14, 2017

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.

@bensku
Copy link
Member

bensku commented Apr 15, 2017

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

@bensku
Copy link
Member

bensku commented Apr 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

No branches or pull requests

4 participants