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

Functions which include waiting for a timespan cannot return a value #7100

Open
1 task done
Budgo opened this issue Sep 20, 2024 · 5 comments
Open
1 task done

Functions which include waiting for a timespan cannot return a value #7100

Budgo opened this issue Sep 20, 2024 · 5 comments

Comments

@Budgo
Copy link

Budgo commented Sep 20, 2024

Skript/Server Version

https://imgur.com/a/4BPA9Ez

Bug Description

Let's say we have a function x defined as follows:

function x(num1: integer) :: blocks:
    wait a tick
    return all blocks within {location1} and {location2} + {num1}

Upon reloading the Skript containg the function, the error "The return effect can only be use in functions, custom expressions, sections, custom syntax parse sections, and custom conditions"

Expected Behavior

I expect the Skript to reload with no errors.

Steps to Reproduce

Create a new Skript file. Paste the following:

function x(num1: integer) :: blocks:
    wait a tick
    return all blocks within {location1} and {location2} + {num1}

Save, then reload the Skript.

Errors or Screenshots

No response

Other

No response

Agreement

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

I'm pretty sure this is intended. Below is my warning when trying your code. I don't think functions allow waits.

> sk reload test
[15:12:55 INFO]: [Skript] Reloading test.sk...
[15:12:55 INFO]: Line 3: (test.sk)
[15:12:55 INFO]:     A return statement after a delay is useless, as the calling trigger will resume when the delay starts (and won't get any returned value)
[15:12:55 INFO]:     Line: return all blocks within {location1} and {location2} + {num1}
[15:12:55 INFO]:  
[15:12:55 INFO]: [Skript] Encountered 1 error while reloading test.sk! (25ms)

@Romitou
Copy link
Member

Romitou commented Sep 20, 2024

Probably related to #4005

@TheLimeGlass
Copy link
Collaborator

TheLimeGlass commented Sep 20, 2024

This has been a known issue for a long time but I don't think there is a issue for it.

Essentially sometimes the error works and sometimes it doesn't. There is a condition that makes the error happen and other times it doesn't. Probably when it's not on the main thread or not on the same event scope.

It should always error.

@sovdeeth
Copy link
Member

The error difference is due to skript-reflect registering a different return effect and a different error.

@TheLimeGlass
Copy link
Collaborator

TheLimeGlass commented Sep 20, 2024

The error difference is due to skript-reflect registering a different return effect and a different error.

Oh I remember now.

So skript-reflect should error if it's not in a custom syntax element, and do so silently, because if it uses Skript.error in the init, Skript won't continue onwards with checking other elements.

Which is what is happening here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants