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

Bug: can't use arithmetics with n-th element out of %objects% #1464

Closed
jaylawl opened this issue Aug 13, 2018 · 3 comments
Closed

Bug: can't use arithmetics with n-th element out of %objects% #1464

jaylawl opened this issue Aug 13, 2018 · 3 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.

Comments

@jaylawl
Copy link
Contributor

jaylawl commented Aug 13, 2018

Skript dev-37c
Spigot 1.12.1

No console or parse errors

Reproduce:

command /test:
    trigger:
        
        add 1, 2, 3 to {_test::*}
        
        set {_a} to 1st element of {_test::*}
        set {_b} to 2nd element of {_test::*}
        set {_c} to 3rd element of {_test::*}
        
        send "%{_a}%"
        send "%{_b}%"
        send "%{_c}%"
        
        set {_a} to ((1st element of {_test::*}) * 2)
        set {_b} to ((2nd element of {_test::*}) * 2)
        set {_c} to ((3rd element of {_test::*}) * 2)
        
        send "%{_a}%"
        send "%{_b}%"
        send "%{_c}%"

The first set of returns will be fine, the latter set will only return 0
I have tried using many variations of parenthesis (), but to no avail

@jaylawl jaylawl changed the title Bug: can't use arithmetics with x-element out of %objects% Bug: can't use arithmetics with x-th element out of %objects% Aug 13, 2018
@jaylawl jaylawl changed the title Bug: can't use arithmetics with x-th element out of %objects% Bug: can't use arithmetics with n-th element out of %objects% Aug 13, 2018
@Snow-Pyon
Copy link

Snow-Pyon commented Aug 18, 2018

Can someone else confirm this? Skript is perhaps returning null since the return type of the element expression is not a number type but rather, an object.

@Blueyescat
Copy link
Contributor

Blueyescat commented Aug 18, 2018

@Snow-Pyon i can confirm, but not only for n-th element it is valid for whole ExprElement.

@TheBentoBox TheBentoBox added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. labels Aug 18, 2018
@Blueyescat
Copy link
Contributor

Blueyescat commented Nov 5, 2018

This is because
https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/expressions/ExprElement.java#L109-L111
Return type of a variable expression = object, so (first element of 1 and 2) + 3 works fine. Is it actually possible to fix this? Maybe with the variable type hint thing..

@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Aug 10, 2021
@TPGamesNL TPGamesNL 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 Aug 30, 2021
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. completed The issue has been fully resolved and the change will be in the next Skript update. 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

6 participants