Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Nametag for player?
- decorp
-
Scratcher
100+ posts
Nametag for player?
In my platformer, I want you to type in a name you want, and then have it appear over your head for the rest of the game. how? I already know how to use the
ask [choose a username] and waitblocks, and already have all of the text in one sprite. hope this makes sense!
- CatsUnited
-
Scratcher
1000+ posts
Nametag for player?
when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)
- decorp
-
Scratcher
100+ posts
Nametag for player?
I don't want to use the say or think blocks.when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)
- CatsUnited
-
Scratcher
1000+ posts
Nametag for player?
I don't want to use the say or think blocks.when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)
... ::grey // everything up to the say partRender text is on the text sprite with each alphanumeric character on it.
render text :: custom
define render text
set [i v] to [1]
clear
go to x: (0) y: (0) // or whatever
repeat (length of (user))
switch costume to (letter (i) of (user))
stamp
change y by (25) // or whatever
change [i v] by (1)
end
Last edited by CatsUnited (March 8, 2015 05:53:42)
- decorp
-
Scratcher
100+ posts
Nametag for player?
thanks!I don't want to use the say or think blocks.when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)... ::grey // everything up to the say partRender text is on the text sprite with each alphanumeric character on it.
render text :: custom
define render text
set [i v] to [1]
clear
go to x: (0) y: (0) // or whatever
repeat (length of (user))
switch costume to (letter (i) of (user))
stamp
change y by (25) // or whatever
change [i v] by (1)
end
- decorp
-
Scratcher
100+ posts
Nametag for player?
thanks!I don't want to use the say or think blocks.when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)... ::grey // everything up to the say partRender text is on the text sprite with each alphanumeric character on it.
render text :: custom
define render text
set [i v] to [1]
clear
go to x: (0) y: (0) // or whatever
repeat (length of (user))
switch costume to (letter (i) of (user))
stamp
change y by (25) // or whatever
change [i v] by (1)
end
but there is a problem. I want the text to follow the user around, and there is also a clone of the last letter right at the end.
Last edited by decorp (March 8, 2015 21:45:29)
- digthebone
-
Scratcher
500+ posts
Nametag for player?
well then you will have to use the say or think blocks.thanks!I don't want to use the say or think blocks.when green flag clicked
ask [Enter a name] and wait
set [user v] to (answer)
say (user)... ::grey // everything up to the say partRender text is on the text sprite with each alphanumeric character on it.
render text :: custom
define render text
set [i v] to [1]
clear
go to x: (0) y: (0) // or whatever
repeat (length of (user))
switch costume to (letter (i) of (user))
stamp
change y by (25) // or whatever
change [i v] by (1)
end
but there is a problem. I want the text to follow the user around, and there is also a clone of the last letter right at the end.
Sorry.
- Cyoce
-
Scratcher
500+ posts
Nametag for player?
The render text works, just need to modify it:
First, to move the text, simply remove the previous text (via `clear`), and redraw it. Then, hide the sprite so you can't see the last letter.
First, to move the text, simply remove the previous text (via `clear`), and redraw it. Then, hide the sprite so you can't see the last letter.
when green flag clicked
ask [Name?] and wait
forever
clear
go to [player v]
show
render text :: custom-arg
hide
end
- LeedleMaster
-
Scratcher
55 posts
Nametag for player?
The render text works, just need to modify it:that would work
First, to move the text, simply remove the previous text (via `clear`), and redraw it. Then, hide the sprite so you can't see the last letter.when green flag clicked
ask [Name?] and wait
forever
clear
go to [player v]
show
render text :: custom-arg
hide
end
YEA BRO
did it work?
- decorp
-
Scratcher
100+ posts
Nametag for player?
The render text works, just need to modify it:
First, to move the text, simply remove the previous text (via `clear`), and redraw it. Then, hide the sprite so you can't see the last letter.when green flag clicked
ask [Name?] and wait
forever
clear
go to [player v]
show
render text :: custom-arg
hide
end
this works a little, but kind bugs me, no offence. I had to mess with it a little to get it to even be seen.
- deck26
-
Scratcher
1000+ posts
Nametag for player?
Each call to ‘render text’ will clear the screen though so if you have multiple users this will surely fail? I suspect you need a single script that clears the screen and writes all the names. It also means you can't use stamping elsewhere in the project at the same time as this.
I guess an alternative is clones, one per letter of the user name and they move around in unison.
I guess an alternative is clones, one per letter of the user name and they move around in unison.
- MegaApuTurkUltra
-
Scratcher
1000+ posts
Nametag for player?
My tip: use say blocks. I'm making a game that uses a lot of clones and pen, and rendering text is simply too slow. Usernames in my game will just be say blocks.
I mean there's a reason griffpatch used say blocks in terraria. Maybe laziness, but probably lag issues.
I mean there's a reason griffpatch used say blocks in terraria. Maybe laziness, but probably lag issues.
- deck26
-
Scratcher
1000+ posts
Nametag for player?
I'd agree with @MegaApuTurkUltra - say/think are both going to much better than anything else you could do if the text is varying. Why are you so keen to avoid using them?
- decorp
-
Scratcher
100+ posts
Nametag for player?
Because it looks professional to have a text sprite over your head instead of say or think, which look kinda silly. Sorry for being a noob 

- Discussion Forums
- » Help with Scripts
-
» Nametag for player?