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

x% of y expression #2692

Closed
ghost opened this issue Dec 14, 2019 · 14 comments
Closed

x% of y expression #2692

ghost opened this issue Dec 14, 2019 · 14 comments
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).

Comments

@ghost
Copy link

ghost commented Dec 14, 2019

Description

Having skript remove a percentage of a number results in skript removing the decimal version instead of the percentage of the original number.

Steps to Reproduce

command /percent <number>:
	usage: /percent (number)
	trigger:
		set {_skmath} to arg 1-1%
		message "Skript Math: %{_skmath}%"
		
		set {_math} to 0.01*arg 1
		set {_math} to arg 1-{_math}
		message "Manual math: %{_math}%"

Expected Behavior

For example set {_math} to 100-1% results in 99.99 because it translates 1% to 0.01 instead of 1% of 100 before removing the amount.

Errors / Screenshots

https://imgur.com/a/zWXNJOM

Server Information

Minecraft: 1.14.4
Paper: 234
Spigot: git-Spigot-56f8471-3e3818b (MC: 1.14.4)
Skript: 2.4 Stable

Additional Notes

I don't think this is intended, so I'm sorry if it is. This is quite confusing, and I didn't see another way to take a percentage value of a number within Skript (for example set {_math} to 1% of 100).

@Wealthyturtle
Copy link
Member

I'm not too sure what you mean here, 1% is 0.01, and Skript is not wrong in that respect.

@ghost
Copy link
Author

ghost commented Dec 14, 2019

I'm not too sure what you mean here, 1% is 0.01, and Skript is not wrong in that respect.

Yes but 1% of 100 is 1. Skript hasn't always translated 1% into decimals like it is now. It's rather confusing and honestly pretty useless.

To clarify a little more set {_math} to 100-1% results in 99.99 because it translates 1% to 0.01 instead of 1% of 100. I don't believe this has always worked this way, but I don't recall many times of needing a percentage.

@bluelhf
Copy link
Contributor

bluelhf commented Dec 14, 2019

@ThePumpkin5822 Not sure how you think percentages are calculated, but you surely don't do it by removing 1% from the value. Skript is right here. To get 99 from this, do 100 - (100 * 1%)

@ghost
Copy link
Author

ghost commented Dec 14, 2019

@ThePumpkin5822 Not sure how you think percentages are calculated, but you surely don't do it by removing 1% from the value. Skript is right here. To get 99 from this, do 100 - (100 * 1%)

That is utterly useless and confusing for new users. I can do the exact same thing with 0.01.
set {_math} to {var}-(0.01*{var})

@bluelhf
Copy link
Contributor

bluelhf commented Dec 14, 2019

@ThePumpkin5822 Please refer to this image

@ghost
Copy link
Author

ghost commented Dec 14, 2019

@ThePumpkin5822 Please refer to this image

You're saying math is useless? Brilliant. @bensku What are your thoughts on this?

@bluelhf
Copy link
Contributor

bluelhf commented Dec 14, 2019

@ThePumpkin5822 Please refer to this image

You're saying math is useless? Brilliant. @bensku What are your thoughts on this?

Where did you get that? Also, according to calculators (but, as far as I can see, no official documentation), this issue is valid, and 100-1% is 99, not 99.99. Skript would probably need to implement special handling for this — this seems counter-intuitive (Percentages can be treated as division, division before subtraction, lots of stuff is broken).

@ghost
Copy link
Author

ghost commented Dec 14, 2019

@ThePumpkin5822 Please refer to this image

You're saying math is useless? Brilliant. @bensku What are your thoughts on this?

Where did you get that?

You are enforcing your point with the image that 1% is 0.01 regardless of the fact the value should be of the original number. Since adding percentages as their are now would be useless because it's not only invalid, there's already a way to do that within Skript.

@Wealthyturtle
Copy link
Member

I have no idea when Skript's behavior changed, but Skript is correct that 1% is 0.01. What you want instead is an expression that provides the value for x% of %number% where x is some number - which Skript as of 2.4 does not have. As such, I'll mark this as an enhancement request.

@Wealthyturtle Wealthyturtle added enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. labels Dec 14, 2019
@bluelhf
Copy link
Contributor

bluelhf commented Dec 14, 2019

@Wealthyturtle After looking at it, this does look weird to me, as a standard calculator would get 99 from this, not 99.99 (Source: Samsung A6 built-in calculator, WolframAlpha, Google)

@Wealthyturtle
Copy link
Member

¯_(ツ)_/¯

@TPGamesNL
Copy link
Member

I feel like 1% is not equal to any number, if no context is given. A percentage is a number to describe a part of a whole, and is therefore not equal to any number. If you use it in a calculation, such as 500 + 1%, the percentage (1%) would represent 1% of the 500, so the 1% is in this scenario equal to (1/100 * 500), so 500 + 1% should return 505.
This can be implemented, but it would probably require a new type for percentages, which can be used in some of the arithmetic expressions (or you add an optional percentage sign to the required arithmetic expressions).

@Wealthyturtle Wealthyturtle added priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements). and removed priority: low Issues that are not harmful to the experience but are related to useful changes or additions. labels Dec 17, 2019
@nopeless
Copy link

I suggest not changing this behavior
percents should always be used with a value multiplied by it
that code above is hard to understand anyway

@Wealthyturtle Wealthyturtle changed the title Skript using percentages as decimals instead of percentage of number x% of y expression Dec 22, 2019
@jaylawl
Copy link
Contributor

jaylawl commented Jan 6, 2020

Rule of thumb: if you use sufficient parenthesis, Skript will eventually do what you want it to

@sovdeeth sovdeeth added the PR available Issues which have a yet-to-be merged PR resolving it label Aug 28, 2023
@AyhamAl-Ali AyhamAl-Ali 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 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).
Projects
None yet
Development

No branches or pull requests

8 participants