Hi all,
I need help with a script whereby a sprite asks a question and the only logical answer is a numerical value. If a letter is entered, how can I reject it?
I've already tried creating a list with all the letters in it to no avail...
<if><( answer <=> letterlist )>
<say[ wrong! ]for( 4 )secs>
Any ideas?
Luke.
Offline
Take a look at the list block "contains"...it will do what you want.
if <letterlist Contains answer >
Say Wrong! for 4 secs
Offline
Paddle's method will work great, but here's a little trick for figuring out if something isn't a number:
How it works:
If you multiply a non-number by any number in Scratch, it will give you 0, so if you get 0 by multiplying the answer by 1 and that answer is not 0 itself, then you know the answer must be a non-number.
Offline
Nice method scmb1. Lol, I was going to suggest breaking it apart letter by letter into a list and checking each individual item. Yours is much better time-wise and efficiency-wise.
Offline
scmb1 wrote:
Paddle's method will work great, but here's a little trick for figuring out if something isn't a number:
http://img155.imageshack.us/img155/8771 … hecker.gif
How it works:
If you multiply a non-number by any number in Scratch, it will give you 0, so if you get 0 by multiplying the answer by 1 and that answer is not 0 itself, then you know the answer must be a non-number.
Was that from my project?
Offline
scimonster wrote:
scmb1 wrote:
Paddle's method will work great, but here's a little trick for figuring out if something isn't a number:
http://img155.imageshack.us/img155/8771 … hecker.gif
How it works:
If you multiply a non-number by any number in Scratch, it will give you 0, so if you get 0 by multiplying the answer by 1 and that answer is not 0 itself, then you know the answer must be a non-number.Was that from my project?
I guess not, because I think I've seen a script that's almost (or exactly) the same in a project before. I'm sure that's not your project because I think I have seen that project for a long time...
Offline
scimonster wrote:
scmb1 wrote:
Paddle's method will work great, but here's a little trick for figuring out if something isn't a number:
http://img155.imageshack.us/img155/8771 … hecker.gif
How it works:
If you multiply a non-number by any number in Scratch, it will give you 0, so if you get 0 by multiplying the answer by 1 and that answer is not 0 itself, then you know the answer must be a non-number.Was that from my project?
No. Actually, I just thought of it myself. Gee, I thought I was being clever.
Offline
Then who should I give credit to if I want to use this method?
Offline
mathematics wrote:
Then who should I give credit to if I want to use this method?
I don't know who should technically get credit, but I don't care if I get credit for that little script, so give it to scimonster.
Offline