Skript

Skript

743k Downloads

Functions which include waiting for a timespan cannot return a value

Budgo opened this issue ยท 5 comments

commented

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.
commented

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)
commented

Probably related to #4005

commented

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.

commented

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

commented

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.