mit-scratch

How to get the case of a letter in scratch?


I'm trying to turn a string into a number, but apparently Scratch ignores the case when returning the list item of a string. So, how would I make it so that scratch pays attention to the case when giving me the letter's corresponding number?

Edited: string returning with wrong case


Solution

  • The "set costume to (name)" block is case sensitive, so it should solve your problem.

    It looks like you are attempting to convert a ASCII character into a number. You can implement this with the following steps:

    If you want to convert a number back into ASCII you can use the following steps:

    The only obvious downside to using this method is that encoding or decoding will change the current costume of the sprite, so I usually make a separate sprite if I want to use costumes.