Is it possible to check if an answer of a question is equal to a number? I am making a drawing game where you get to choose the color of the pen. Please help! I would really appreciate it! Thanks!
Offline
Use:
If answer*1=answer
When this is true, it's a number. When it's false, it used letters or something other than numbers.
Offline
Do this:
If { [ not (answer) = 0 ] and [ (answer/1) = 0 ] }
Then answer if a letter.
Else
Answer is a number.
Offline
Kileymeister wrote:
Use:
If answer*1=answer
When this is true, it's a number. When it's false, it used letters or something other than numbers.
lemonpretzel wrote:
Do this:
If { [ not (answer) = 0 ] and [ (answer/1) = 0 ] }
Then answer if a letter.
Else
Answer is a number.
Wow, we posted at the exact same time! 20:10:17
Offline
lemonpretzel wrote:
Kileymeister wrote:
Use:
If answer*1=answer
When this is true, it's a number. When it's false, it used letters or something other than numbers.lemonpretzel wrote:
Do this:
If { [ not (answer) = 0 ] and [ (answer/1) = 0 ] }
Then answer if a letter.
Else
Answer is a number.Wow, we posted at the exact same time! 20:10:17
Holy cow. And we both had similar answers that both work.
Haha, I win by a second or something though.
Last edited by Kileymeister (2011-03-17 20:15:04)
Offline
Offline
Aww, it didn't work. Also for yours lemon pretzel it just needs a letter in it.
Offline
I mean number. Also kileymeister's works but I am trying to make it change the pen color and that won't work.
Offline
lemonpreztel's looks dodgy, especially knowing that scratch looks at the last boolean in an AND block to see if it's true...
Offline
ImagineIt wrote:
I mean number. Also kileymeister's works but I am trying to make it change the pen color and that won't work.
![]()
"Set pen color to answer" won't work? Are you sure it's the correct sprite that's changing its pen color?
Offline
I use:
[blocks]
<if> << <( (( answer <-> 0 )) <=> 0 )> <and><< <not> <( answer <=> 0 )> >> >>
<set{ letter or number }to( letter
<else>
<set{ letter or number }to( number
[/blocks]
~Pecola1
Last edited by YourLocalBlockLib (2011-03-19 09:34:12)
Offline
I use this:
<< <( <{ x }> <>> 0 )> <or> << <( x <<> 0 )> <or> <( <{ x }> <=> 0 )> >> >>
Offline