Discuss Scratch

Domo900
Scratcher
21 posts

How do I switch a number in a variable to a whole number?

I know how to do the Round () block for this, but I need to know how to change it to a whole number. This is how my game works. It has points, and when you lose, they get exchanged into a different currency. It is 10000 Points / 1 Token. When I divide 10000/1 with 10000 points, I should get 1 Token. If I use the Rounding block and I divide, let's say, 17500/1, I would get two Tokens. But I only want one. I want it to be every 10000 points is a token. Even if it's just barely under 20000 points, I still want one, because it isn't quite 20000.


Bite-Sized Awesomesauce.
ErnieParke
Scratcher
1000+ posts

How do I switch a number in a variable to a whole number?

Instead of using rounding, I recommend you use floor:

([floor v] of (numbers))

That way when it comes time to exchange currency, all you have to do is:

change [Tokens v] by ([floor v] of ((Points) / (10000)))

It's a neat little trick, as you can see. ;)

Showing,

ErnieParke

Domo900
Scratcher
21 posts

How do I switch a number in a variable to a whole number?

ErnieParke wrote:

Instead of using rounding, I recommend you use floor:

([floor v] of (numbers))

Thanks!!

Bite-Sized Awesomesauce.
ErnieParke
Scratcher
1000+ posts

How do I switch a number in a variable to a whole number?

Domo900 wrote:

ErnieParke wrote:

Instead of using rounding, I recommend you use floor:

([floor v] of (numbers))

Thanks!!
You're welcome @Domo900!

Happy,

ErnieParke

Powered by DjangoBB