ID:1418934
 
(See the best response by Makeii.)
Problem description:

Hello guys, after seeing how dull my current maptext system is, I was looking around at other games trailers when suddenly I was intrigued by the fascinating "Typing Effect" seen on some games such as Resurrection. I've got absolutely no idea on how to take this approach. I've already got my maptext code all done. This is just something I was inspired by in order to make my game fancier and more realistic. Anybody have any feedback on how I should go about this?

-Thanks
Best response
Basucally what is happening in the "typing effect" is each character is being added to maptext one at a time. A sleep call is placed between each adding of a character to allow the screen to update appropriately.

It works something like this:

var/sometext = "This is some text."
mob/proc/AddMapText()
maptext = "<font color=white>"
var/d = length(sometext)
for (var/i = 1 to d)
maptext += copytext(sometext,i,i+1)
sleep(world.tick_lag)
Exactly what Makeii said, you continuously keep adding new characters, you can actually pull off it with something like an extra character at the end such as "_" or "|" to signify that it is typing or what not, but that woud require some modification in terms of code, not too difficult however.

var/sometext = "This is some text."
mob
maptext="<font color=white>"
var
endMark="_"
proc
AddMapText()
maptext = initial(maptext)
for (var/i = 1 to length(sometext))
maptext = copytext(sometext,1,i+1)+endMark
sleep(world.tick_lag)
maptext=sometext

In multiplayer I wouldn't recommend this as it would increase the network traffic, as I am aware of.
It can't be by much, right? maptext rendering is off-loaded to the client.
maptext's graphical appearance doesn't require any input from the server other than what the text is supposed to be. However, if over a multiplayer game you want to change maptext every tick, it can produce a lot of network traffic if a lot of players are doing this at the same time. The main reason why it's a bit of a hassle is because it's dealing with strings, which are always less efficient than numbers.

Thinking on it more, I don't think network-wise it's not THAT much of an issue. I'm thinking if a server was holding over 50 players all doing this at the same time. With about 5 players it shouldn't make much of a difference.
As Makeii said, it won't be too much of an issue when only a few people are using it at a time, but when it is massively used it will be. Would be better to display the message at once in multiplayer, the effect isn't worth that much. Of course you could apply the effect in a form where it uses more than 1 character every tick.
atom
maptext="<font color=#ffffff>" // Initial maptext formating.
var
maptextWriteRate=2 // How many characters to print at a time.
endMark="_" // The symbol you want to display at the end of the text when it is typed.
proc
displayMapText(text)
maptext=initial(maptext) // Sets the maptext as it's initial value to get it's formating
for(var/i=maptextWriteRate to length(text) step maptextWriteRate) // Runs the for() loop with a step of maptextWriteRate, instead of the increments of one.
maptext=copytext(text,1,i+1)+endMark // Sets maptext to be at the length of i and adds the endMark to it.
sleep(world.tick_lag) // Sleeps for world.tick_lag.
maptext=text // Sets the maptext into the final value of text.