Discuss Scratch

Nexus_uno
Scratcher
3 posts

What can i use for "any multiple of" as coding in scratch?

I have a glitch that only happens on the multiple of a specific number but it stops glitching when i set an if the variable equals the number or a multiple of the number it fixes, but i don't want to type it out for each equation so I looked for something to represent that and could not find it.
drmcw
Scratcher
1000+ posts

What can i use for "any multiple of" as coding in scratch?

mod

So number mod 2 = 0 when number is even.
Nexus_uno
Scratcher
3 posts

What can i use for "any multiple of" as coding in scratch?

drmcw wrote:

mod

So number mod 2 = 0 when number is even.

I'm not understanding; my program is here -> http://scratch.mit.edu/projects/41873706/#editor
a note is written in the stage at the problematic point.

Last edited by Nexus_uno (Jan. 16, 2015 08:19:08)

ShadowScizor
Scratcher
100+ posts

What can i use for "any multiple of" as coding in scratch?

mod
takes the remainder of the division

For example:
5mod2
equals to 1
as 5/2 will give a remainder of 1.
Hence if the second number is the multiple of the first number, the result will be 0.
eg.
6mod3
equals 0
TheLogFather
Scratcher
1000+ posts

What can i use for "any multiple of" as coding in scratch?

The quickest way to fix it is to get rid of that script at the top left of Stage which is checking abs(round(ScrollX)) all the time, and use round((ScrollX-1)/480) in the script below (i.e. subtract 1 from ScrollX).

That makes enough of a difference at the critical halfway point to get the Platforms calculations to work out in the way you want.

Nexus_uno
Scratcher
3 posts

What can i use for "any multiple of" as coding in scratch?

TheLogFather wrote:

The quickest way to fix it is to get rid of that script at the top left of Stage which is checking abs(round(ScrollX)) all the time, and use round((ScrollX-1)/480) in the script below (i.e. subtract 1 from ScrollX).

That makes enough of a difference at the critical halfway point to get the Platforms calculations to work out in the way you want.

Thank you. From what i can tell this fix worked perfectly.
garrythepotato11
Scratcher
2 posts

What can i use for "any multiple of" as coding in scratch?

so if it is the number is 20 what would the mod be
duckboycool
Scratcher
1000+ posts

What can i use for "any multiple of" as coding in scratch?

garrythepotato11 wrote:

so if it is the number is 20 what would the mod be
Please check the date of the topic before posting.

Nothing as mod requires two inputs. This is how it works.
asivi
Scratcher
1000+ posts

What can i use for "any multiple of" as coding in scratch?

garrythepotato11 wrote:

so if it is the number is 20 what would the mod be

You question makes no sense, if you want to know if a number is a multiple of another, let say, Is 24 multiple of 3?
if24mod3=0then24ismultipleof3

duckboycool wrote:

garrythepotato11 wrote:

so if it is the number is 20 what would the mod be
Please check the date of the topic before posting.

Nothing as mod requires two inputs. This is how it works.
Harakou
Scratcher
1000+ posts

What can i use for "any multiple of" as coding in scratch?

duckboycool wrote:

garrythepotato11 wrote:

so if it is the number is 20 what would the mod be
Please check the date of the topic before posting.

Nothing as mod requires two inputs. This is how it works.
Thanks. Here's the Scratch wiki article on the mod block, with a bunch of examples on how to use this. I'll close this thread since OP's question seems to be resolved. @garrythepotato11, if you have further questions you should make your own thread. Thanks!

Powered by DjangoBB