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:
(report)Then add this script where you need to check the input:
if <(input) = ((1) * (input))> //Replace "input" with the actual input. set [report v] to [number] else set [report v] to [string] endThe variable "report" will say "number" if it is a number, and "string" if it is not.
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
if <<(input) = ((1) * (input))> or <(input) = [0]>> //Replace "input" with the actual input. set [report v] to [number] else set [report v] to [string] end
Last edited by bobbybee (2012-02-20 06:17:05)
Offline
bobbybee wrote:
if <<(input) = ((1) * (input))> or <(input) = [0]>> //Replace "input" with the actual input. set [report v] to [number] else set [report v] to [string] end
How does this help? (not criticizing)
Offline
360-International wrote:
bobbybee wrote:
if <<(input) = ((1) * (input))> or <(input) = [0]>> //Replace "input" with the actual input. set [report v] to [number] else set [report v] to [string] endHow 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:
if <<(input) = ((1) * (input))> or <(input) = [0]>> //Replace "input" with the actual input. set [report v] to [number] else set [report v] to [string] endHow 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,
<(input) = ((1) * (input))>equals true, which will report "number". And 0 IS a number.
Offline
An example of what you could use it for:
when gf clicked forever ask [Enter a number or string] and wait if <(answer) = <(1) * (answer)>> say [Number] for (2) secs else say [String] for (2) secs endAnd yes, inputting a zero will work.
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,
<(input) = ((1) * (input))>equals true, which will report "number". And 0 IS a number.
Oh, you're right. I didn't realize that. XD
Offline
Doh!
Offline
Topic closed
Pages: 1