Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I get the Last Letter of a Variable?
- 91108293
- Scratcher
80 posts
How do I get the Last Letter of a Variable?
I have a project that needs the last letter of the answer, no matter how long the answer is. Here's how it works: The game would ask the player a question, and the answer it recieved would be set to a variable. Certain things would change to certain costumes depending on the first letter of the variable, and certain things would change to other costumes depending on the last letter of the variable. What should I do?
WINDOWS 7 FOR THE WIN!!
- Despicable_Dad
- Scratcher
500+ posts
How do I get the Last Letter of a Variable?
set [last letter v] to (letter (length of (original)) of (original))
I'm a Scratch Wiki contributor, and always keen to know which bits of the wiki are unclear. If I can, I'll try to improve things; otherwise, I'll make sure it's brought to the attention of someone who actually knows what they're talking about.
if <not <touching color [#3d4fe4] ?>> then
return true anyway cos computers are vague, innit
change [scratchFoibles v] by (1)
end
if <[a] = [A]> then
think [What???]
change [scratchFoibles v] by (1)
end
- 91108293
- Scratcher
80 posts
How do I get the Last Letter of a Variable?
Thank you!
WINDOWS 7 FOR THE WIN!!
- Discussion Forums
- » Help with Scripts
- » How do I get the Last Letter of a Variable?