This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-11-30 16:40:15

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

How to tell if a number entered is odd or even?

The level system in my game works by adding two to the level variable every level (because each level has two costumes). I'd like to do a level select cheat, but I'm doing it by asking the player what level they'd like to go to. If the answer is even, then the cheat doesn't work and the game breaks. How can I make sure that the number is always odd (without having to tell the player to enter an odd number)?


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#2 2010-11-30 16:53:04

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: How to tell if a number entered is odd or even?

if <(answer mod 2) = 0> then
JUMPLEVELCODE
else
BREAKLEVEL


http://i46.tinypic.com/dw7zft.png

Offline

 

#3 2010-11-30 17:13:51

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to tell if a number entered is odd or even?

SeptimusHeap wrote:

if <(answer mod 2) = 0> then
JUMPLEVELCODE
else
BREAKLEVEL

Alright, thanks  smile .


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#4 2010-11-30 17:22:32

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Another way:

Code:

if((number/2) = round(number/2)) ...

Captain Superfluous saves the day.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5 2010-11-30 18:05:02

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to tell if a number entered is odd or even?

fullmoon wrote:

Another way:

Code:

if((number/2) = round(number/2)) ...

Captain Superfluous saves the day.

That's easier to use since I don't know what mod does  big_smile .


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#6 2010-11-30 18:15:54

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Sunrise-Moon wrote:

fullmoon wrote:

Another way:

Code:

if((number/2) = round(number/2)) ...

Captain Superfluous saves the day.

That's easier to use since I don't know what mod does  big_smile .

"Mod" is short for "modulus", which is basically a fancy word for the remainder of a division operation. So 23 mod 7 is 2 because 7 goes into 21 evenly with 2 left over.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#7 2010-11-30 19:21:57

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: How to tell if a number entered is odd or even?

If you want to know what a block does... look it up on the Scratch Wiki  big_smile   big_smile   big_smile  Scratch Wiki article


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#8 2010-11-30 21:40:35

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Jonathanpb wrote:

If you want to know what a block does... look it up on the Scratch Wiki  big_smile   big_smile   big_smile  Scratch Wiki article

xD ok. On the subject of the Scratch Wiki, my username doesn't work with the password that was assigned to me.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#9 2010-12-01 00:27:47

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Sunrise-Moon wrote:

Jonathanpb wrote:

If you want to know what a block does... look it up on the Scratch Wiki  big_smile   big_smile   big_smile  Scratch Wiki article

xD ok. On the subject of the Scratch Wiki, my username doesn't work with the password that was assigned to me.

Really?  hmm  Try copying and pasting in the password given to you to make sure that you didn't take a l for an I or something like that. Make sure that the account name you put in at the login is the exact same as your Scratch username (don't do Sunrise-moon when your Scratch username is Sunrise-Moon, those types of things). If it still doesn't work, sowwee (I was the one who created your account, so if something went wrong with the password it's my fault xD) - e-mail scratcherswiki@scratch.mit.edu, stating the problem (I think that's the wiki's e-mail address), or just give JSO a comment about it  tongue

Last edited by Jonathanpb (2010-12-01 00:31:47)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#10 2010-12-01 00:40:52

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Jonathanpb wrote:

Sunrise-Moon wrote:

Jonathanpb wrote:

If you want to know what a block does... look it up on the Scratch Wiki  big_smile   big_smile   big_smile  Scratch Wiki article

xD ok. On the subject of the Scratch Wiki, my username doesn't work with the password that was assigned to me.

Really?  hmm  Try copying and pasting in the password given to you to make sure that you didn't take a l for an I or something like that. Make sure that the account name you put in at the login is the exact same as your Scratch username (don't do Sunrise-moon when your Scratch username is Sunrise-Moon, those types of things). If it still doesn't work, sowwee (I was the one who created your account, so if something went wrong with the password it's my fault xD) - e-mail scratcherswiki@scratch.mit.edu, stating the problem (I think that's the wiki's e-mail address), or just give JSO a comment about it  tongue

Ah, it was a problem with the username (lack of capitals). Alright, thanks for the help  big_smile .


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#11 2010-12-01 00:54:28

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: How to tell if a number entered is odd or even?

Sunrise-Moon wrote:

Jonathanpb wrote:

Sunrise-Moon wrote:


xD ok. On the subject of the Scratch Wiki, my username doesn't work with the password that was assigned to me.

Really?  hmm  Try copying and pasting in the password given to you to make sure that you didn't take a l for an I or something like that. Make sure that the account name you put in at the login is the exact same as your Scratch username (don't do Sunrise-moon when your Scratch username is Sunrise-Moon, those types of things). If it still doesn't work, sowwee (I was the one who created your account, so if something went wrong with the password it's my fault xD) - e-mail scratcherswiki@scratch.mit.edu, stating the problem (I think that's the wiki's e-mail address), or just give JSO a comment about it  tongue

Ah, it was a problem with the username (lack of capitals). Alright, thanks for the help  big_smile .

smile   smile   smile   smile   smile   smile   smile   smile   smile   smile


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

Board footer