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

Using a function as a list in a contain effect doesn't work #3874

Closed
AzonFR opened this issue Apr 2, 2021 · 3 comments
Closed

Using a function as a list in a contain effect doesn't work #3874

AzonFR opened this issue Apr 2, 2021 · 3 comments
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.

Comments

@AzonFR
Copy link

AzonFR commented Apr 2, 2021

Description

When using a function as a list in a contain effect it doesn't work
But we can use if whitelist() where [input = {_p}'s name] is set:

Steps to Reproduce

function whitelist() :: texts:
  return "Azon_FR", "Azon_DC1", "Azon_DC2" and "Azon_DC3"

function connect(p: player, s: text):
  loop whitelist():
    broadcast "%loop-value% %{_p}'s name%"
    loop-value = {_p}'s name
    broadcast "&atrue"
  if whitelist() contain {_p}'s name:
    broadcast "&acontain"
  else:
    broadcast "&cdoesn't contain"

Expected Behavior

It should send "contain" because whitelist() contain my name

Errors / Screenshots

Server Information

  • Server version/platform: Spigot 1.8.8
  • Skript version: 2.5.3 fork for 1.8
@bluelhf
Copy link
Contributor

bluelhf commented Apr 2, 2021

The issue tracker supports only 1.9.4 and above

@FranKusmiruk FranKusmiruk added the invalid Not a Skript issue, already implemented, does not apply, etc. label Apr 3, 2021
@Matocolotoe
Copy link
Contributor

The issue tracker supports only 1.9.4 and above

This issue occurs in 1.9+ though :)

image

function whitelist() :: texts:
  return "Giovanni75", "Azon_DC1", "Azon_DC2" and "Azon_DC3"

function connect(p: player, s: text):
  loop whitelist():
    broadcast "%loop-value% %{_p}'s name%"
    loop-value = {_p}'s name
    broadcast "&atrue"
  if whitelist() contain {_p}'s name:
    broadcast "&acontain"
  else:
    broadcast "&cdoesn't contain"

@TPGamesNL
Copy link
Member

TPGamesNL commented Apr 3, 2021

This happens because CondContains handles string differently from other objects, examples:
("abc" and "def") contains "abc" returns false, because abc does contain the text abc, but def doesn't.
("abc" or "def") contains "abc" returns true, because now or is used instead of and.
You can use the alternative syntax [the] list [of] %objects% contain[s] %objects% to always use object list comparisons.

The reason this behaviour isn't noticed that much, is because it doesn't work properly for list variables, these are checked as a list of objects.
Related: #2439, #3014

@TPGamesNL TPGamesNL reopened this Apr 3, 2021
@TPGamesNL TPGamesNL added enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. and removed invalid Not a Skript issue, already implemented, does not apply, etc. labels Apr 3, 2021
@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Apr 29, 2021
@APickledWalrus APickledWalrus added completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.
Projects
None yet
Development

No branches or pull requests

7 participants