So it seems like there is a big bug with function returns. The problem, I think, is that returns aren never deleted but are still stored when we use a function multiple times. If a function returns something, as longer as the function can't return something, it will return the old return!
Example:
function(t: text) :: text:
if {_t} is "hey!":
return "lol"
Here, if "{_t}" is hey just one time, the function will always return "lol" all the next times, either if the text isn't "hey!" It's, I think, an important issue...
The only workaround about that is be do add:
if {_t} is not "hey!":
return "ah, no!"
function func(t: text) :: text:
if {_t} is "hey!":
broadcast {_t}
return "lol"`
and the output:

It's because Skript doesn't error when a return statement is missing, so it takes the only.one instead, undepending on the conditions that led to it
Yeah, this is weird but it's honestly a fault of your code. Not all of your possible paths return something. In most languages that wouldn't even compile for that very reason.
I wouldn't even consider this a bug since it's on the user to write their functions correctly and return something if they say they're going to, though at the same time if it's at all feasible a nice enhancement would be to make functions that don't return something at all paths throw an error and not load. I don't see that being easy, though, and it's not really necessary, so it's up to bensku (personally I don't think it's worth the time unless it's way easier to do than I expect. since this isn't a problem for correctly written functions).
(Oops clicked close and comment instead of just comment #mobile)
I think it will be wayyy easier with the scope API that's coming, since you can just get all items in a trigger section
That definitely would make it easier.
Well actually you could simply implement it already, since it's just about creating a field and setting it in a method, but there's lots of other stuff too, as you know
@TheBentoBox @Snow-Pyon this can be closed now
Let's not talk about what I had said here, shall we ?
Most helpful comment
Let's not talk about what I had said here, shall we ?