Discuss Scratch

TheVaultBoy
New Scratcher
3 posts

Putting variables into one sentence using the "Say/Think" blocks

I am creating something that is kind of like an rpg, and certain characters will call you by your name, which you input at the beginning of the game. In order to do that, I created a variable called “name”. When you input your name, it changes that variable to equal whatever you put in there. Assuming these images work, this is what I have set up.

What I want to do, is when people are talking to you, they can say: “Hello, {Whatever name is set to}, how are you?” Although I cannot seem to get it to do that. Putting the name variable into the text zone doesn't solve the problem, either, because all that does is overwrite what was already there. If anyone can help that would be really good. Thanks.
TheVaultBoy
New Scratcher
3 posts

Putting variables into one sentence using the "Say/Think" blocks

edit: the images didnt work lol
sayDARN
Dan0510
Scratcher
100+ posts

Putting variables into one sentence using the "Say/Think" blocks

Does this help?
sayjoinHello, joinname, how are you?

You could also use the username block instead of the variable

sayjoinHello, joinusername, how are you?

Last edited by Dan0510 (April 26, 2014 18:31:14)

levtey
Scratcher
100+ posts

Putting variables into one sentence using the "Say/Think" blocks

whenclickedsayjoinjoinHello, name, how are you?

Last edited by levtey (April 26, 2014 18:40:19)

billk123
Scratcher
28 posts

Putting variables into one sentence using the "Say/Think" blocks

Levtey that was an exact copy of the one shown above.
levtey
Scratcher
100+ posts

Putting variables into one sentence using the "Say/Think" blocks

billk123 wrote:

Levtey that was an exact copy of the one shown above.
Sorry, I posted it before I saw the post.
pdpdizon
New Scratcher
1 post

Putting variables into one sentence using the "Say/Think" blocks

This helped me with my project, thanks!
BeeBoy10
Scratcher
48 posts

Putting variables into one sentence using the "Say/Think" blocks

whenclickedifusername= thenaskWhat is your name?andwaitsetnameto(answer) ifnotusername= thensetnameto (username)sayjoinHijoinname!end

Last edited by BeeBoy10 (Jan. 16, 2015 14:47:37)

deck26
Scratcher
1000+ posts

Putting variables into one sentence using the "Say/Think" blocks

BeeBoy10 wrote:

whenclickedifusername= thenaskWhat is your name?andwaitsetnameto(answer) ifnotusername= thensetnameto (username)sayjoinHijoinname!end
I think you mean
whenclickedifusername= thenaskWhat is your name?andwaitsetnameto(answer) elsesetnametousernamesayjoinHijoinname!
d0lf1ns
Scratcher
47 posts

Putting variables into one sentence using the "Say/Think" blocks

These answers are great but isn't he asking how to change the name variable?
deck26
Scratcher
1000+ posts

Putting variables into one sentence using the "Say/Think" blocks

d0lf1ns wrote:

These answers are great but isn't he asking how to change the name variable?
Hopefully it should be obvious enough that you can remove all the username stuff if it's not required. So

whenclickedaskWhat is your name?andwaitsetnameto(answer) sayjoinHijoinname!
xkitox
Scratcher
1 post

Putting variables into one sentence using the "Say/Think" blocks

BeeBoy10 wrote:

whenclickedifusername= thenaskWhat is your name?andwaitsetnameto(answer) ifnotusername= thensetnameto (username)sayjoinHijoinname!end
Thank you!
awesomedudesilas
Scratcher
100+ posts

Putting variables into one sentence using the "Say/Think" blocks

That helped a LOT

Powered by DjangoBB