Skript
Skript copied to clipboard
Create clamp expression
Description
Creates a clamp expression to clamp values between a min and a max. This is my first time working with skript so any help/tips would be appreciated :)
Target Minecraft Versions: any Requirements: none Related Issues: #6488
I think I'd rather fix the function return behaviour than make a syntax for this.
I think I'd rather fix the function return behaviour than make a syntax for this.
there is no bug in function return behavior is works how it's intended to
there is no bug in function return behavior is works how it's intended to
And I'm saying the behaviour is poor and could be done better.
I don't much like this addition as Functions are better fit for this.
I don't much like this addition as Functions are better fit for this.
Same could be said about the ExprRound
class for rounded [1:up|2:down] %numbers%
. This would work as a function if functions actually supported isSingle checks which rolls into Moderocky's mention.
And I'm saying the behaviour is poor and could be done better.
It can't be done better when the function literally can't support set {_blah} to clamp(10.6, 1, 10)
this isn't exclusive to clamp when round function has the same flaw.
It can't be done better when the function literally can't support
set {_blah} to clamp(10.6, 1, 10)
this isn't exclusive to clamp when round function has the same flaw.
Maybe I didn't make it clear, I am recommending we fix the issue with variable arity returns not being permitted in single changers. This would make all such functions work.
I was looking over the clamp function tests but got confused by these three.
assert clamp(1, 0, NaN value) is not clamp(1, 0, NaN value) with "(single ints) min < value < NaN"
assert clamp(1, NaN value, 2) is not clamp(1, NaN value, 2) with "(single ints) NaN < value < max"
assert clamp(NaN value, 1, 2) is not clamp(NaN value, 1, 2) with "(single ints) min < NaN < max"
Why are they getting compared to themselves? I feel like these should be checking if the output is set.
Why are they getting compared to themselves? I feel like these should be checking if the output is set.
If I remember correctly this was one of the ways to check for 'not a number' because it didn't test equal to itself. I don't know if that's still the case anymore and we may have a better way.
Why are they getting compared to themselves? I feel like these should be checking if the output is set.
If I remember correctly this was one of the ways to check for 'not a number' because it didn't test equal to itself. I don't know if that's still the case anymore and we may have a better way.
yes we have isNaN() now!
In that case should it become assert isNaN(clamp(1, 0, NaN value)) is true with "(single ints) min < value < NaN"
?
Or do we want it to be false. I don't really understand what the old check was aiming for
In that case should it become
assert isNaN(clamp(1, 0, NaN value)) is true with "(single ints) min < value < NaN"
? Or do we want it to be false. I don't really understand what the old check was aiming for
yes exactly The original test took advantage of the fact that NaN does not equal NaN, but any other value should equal itself, to test for NaN
Do we still want to move ahead with this now that the function is fixed? I like having the clamped above/below
syntax.