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

Issue with parsing string as single type. #5262

Closed
1 task done
colton-boi opened this issue Dec 23, 2022 · 4 comments
Closed
1 task done

Issue with parsing string as single type. #5262

colton-boi opened this issue Dec 23, 2022 · 4 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

@colton-boi
Copy link
Contributor

colton-boi commented Dec 23, 2022

Skript/Server Version

[02:42:22 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[02:42:22 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[02:42:22 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[02:42:22 INFO]: [Skript] Server Version: git-Pufferfish-52 (MC: 1.19.3)
[02:42:22 INFO]: [Skript] Skript Version: 2.6.3
[02:42:22 INFO]: [Skript] Installed Skript Addons: 
[02:42:22 INFO]: [Skript]  - skript-gui v1.3-beta2 (https://github.com/APickledWalrus/skript-gui)
[02:42:22 INFO]: [Skript]  - DiSky v4.4.3
[02:42:22 INFO]: [Skript]  - skript-reflect v2.3 (https://github.com/TPGamesNL/skript-reflect)
[02:42:22 INFO]: [Skript]  - skRayFall v1.9.28 (https://sk.rayfall.net/)
[02:42:22 INFO]: [Skript]  - SkQuery v4.1.7
[02:42:22 INFO]: [Skript]  - SkriptJSON v1.0.0
[02:42:22 INFO]: [Skript]  - SkBee v2.5.1 (https://github.com/ShaneBeee/SkBee)
[02:42:22 INFO]: [Skript]  - FunkySk v1.0.2
[02:42:22 INFO]: [Skript]  - skript-holo v1.0.2 (https://github.com/Blueyescat/skript-holo)
[02:42:22 INFO]: [Skript] Installed dependencies: 
[02:42:22 INFO]: [Skript]  - Vault v1.7.3-b131

yes I know I have a lot of addons, shush

Bug Description

Setting a variable to string parsed as "test%string%" results in the error variable can only be set to one object, not more, while only a singular object is returned. image

Expected Behavior

No error and the variable being set

Steps to Reproduce

All in the bug description. One way around this is to, instead of setting it to string parsed as "test%string%" setting it to second element of (string parsed as "%string%est%string%") but that shouldn't be necessary

You are also unable to set the variable to first element of string parsed as "test%string%"
image

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@TheLimeGlass
Copy link
Collaborator

TheLimeGlass commented Dec 23, 2022

This has always been intended behavior. Skript cannot grab the string value at parse time, only at runtime. This means Skript can't tell if you used single or multiple expression types in your string.

So in order to be able to support multiple expression types in the string %text% tier %number% the expression has to return false for isSingle indicating multiple values can be present when the custom text parse is used.

A solution could be making the parsed as custom text a literal String which we've been experimenting with in other things but this will remove the usage of variables and expressions etc in the text, or set it to a variable and use the soon to be implemented type hints of variables, but that's not something for awhile. Or maybe even seeing if it'll parse in the init method as I think it may work.

From documentation:

You have to save the expression's value in a list variable, e.g. set {parsed::*} to message parsed as "...".

The list variable will contain the parsed values from all %types% in the pattern in order. If a type was plural, e.g. %items%, the variable's value at the respective index will be a list variable, e.g. the values will be stored in {parsed::1::*}, not {parsed::1}.

@TheLimeGlass TheLimeGlass added the won't fix Intended behaviour of Skript/MC, not fixable or not planned label Dec 23, 2022
@colton-boi
Copy link
Contributor Author

colton-boi commented Dec 23, 2022

If that's the case, just want to comment that running !set {d} to first element of (uncolored name of tool parsed as "text%string%") gives the following error https://pastebin.com/CD6p2iFR

@TheLimeGlass
Copy link
Collaborator

If that's the case, just want to comment that running !set {d} to first element of (uncolored name of tool parsed as "text%string%") gives the following error https://pastebin.com/CD6p2iFR

I cannot reproduce with a diamond sword named "testExample"

@TPGamesNL
Copy link
Member

The pattern of ExprParse is already a literal, so analyzing the pattern to determine whether it will always be single during init is possible and won't break anything. It could also be analyzed to better specify the return type of ExprParse.

The ArrayStoreException will be fixed in #5274.

@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 won't fix Intended behaviour of Skript/MC, not fixable or not planned labels Dec 25, 2022
@TPGamesNL TPGamesNL self-assigned this Dec 25, 2022
@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Dec 25, 2022
@TheLimeGlass TheLimeGlass 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 Dec 26, 2022
@TPGamesNL TPGamesNL added PR available Issues which have a yet-to-be merged PR resolving it and removed completed The issue has been fully resolved and the change will be in the next Skript update. labels Dec 27, 2022
@TheLimeGlass TheLimeGlass 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 Jan 4, 2023
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

4 participants