Pages: 1
Topic closed
Older tutorials: Wall Jumping (12-Feb-01)
This is a quick script to test whether or not a variable's value is a string (text) or a number.
NOTE: This is not the same as checking if something is a word or not.
Make this variable:
Then add this script where you need to check the input:report
The variable "report" will say "number" if it is a number, and "string" if it is not.ifinput=1*inputReplace "input" with the actual input.setreport ▼tonumberelsesetreport ▼tostring
Last edited by 360-International (2012-02-19 20:11:31)
Offline
Very clever...that'll be helpful for games and such that use the ask block.
Offline
iforinput=1*inputinput=0Replace "input" with the actual input.setreport ▼tonumberelsesetreport ▼tostring
Last edited by bobbybee (2012-02-20 06:17:05)
Offline
bobbybee wrote:
iforinput=1*inputinput=0Replace "input" with the actual input.setreport ▼tonumberelsesetreport ▼tostring
How does this help? (not criticizing)
Offline
360-International wrote:
bobbybee wrote:
iforinput=1*inputinput=0Replace "input" with the actual input.setreport ▼tonumberelsesetreport ▼tostringHow does this help? (not criticizing)
It's an improved version. Your version will report "string" if it's a number, but this doesn't.
Offline
scimonster wrote:
360-International wrote:
bobbybee wrote:
iforinput=1*inputinput=0Replace "input" with the actual input.setreport ▼tonumberelsesetreport ▼tostringHow does this help? (not criticizing)
It's an improved version. Your version will report "string" if it's a number, but this doesn't.
Actually, if the input was 0,
equals true, which will report "number". And 0 IS a number.input=1*input
Offline
An example of what you could use it for:
And yes, inputting a zero will work.whenclicked
foreveraskEnter a number or stringand waitifanswer=1*answersayNumberfor2secselsesayStringfor2secs
Offline
Cool.
Offline
rdococ wrote:
scimonster wrote:
360-International wrote:
How does this help? (not criticizing)
It's an improved version. Your version will report "string" if it's a number, but this doesn't.
Actually, if the input was 0,
equals true, which will report "number". And 0 IS a number.input=1*input
Oh, you're right. I didn't realize that. XD
Offline
Doh!
Offline
Topic closed
Pages: 1