ID:269225
Apr 17 2005, 5:47 am
|
|
How would I limit the amount of characters a player can "say"?
|
Apr 17 2005, 5:57 am
|
|
Use length() or lentext().
|
In response to DeathAwaitsU
|
|
Aight, thanks
|
Another effective way to do this is with the copytext() procedure. Here's an example:
mob/verb/say(t as text) That way, flooders will mostly flood themselves and people who accidentally type too long of a message will be able to copy-paste the rest of their message into subsequent say() verbs. If your game has a spam count that triggers based on the number of calls to say() per period of time, one effective way to limit flooders but not legitimate chatters is to break messages up into multiple segments, like so: mob/verb/say(t as text) That recursive procedure will call a different say() for each 80 characters the user inputs, allowing your spam catcher to notice floods of text. However, normal chatters will only end up breaking their text on an occasion. |
In response to PirateHead
|
|
PirateHead wrote:
Another effective way to do this is with the copytext() procedure. Here's an example: > mob/verb/say(t as text) That way, flooders will mostly flood themselves and people who accidentally type too long of a message will be able to copy-paste the rest of their message into subsequent say() verbs. > mob/verb/say(t as text) That recursive procedure will call a different say() for each 80 characters the user inputs, allowing your spam catcher to notice floods of text. However, normal chatters will only end up breaking their text on an occasion. Or, a slightly shorter method: world<<"[src.name]: [length(T)>81 ? copytext(T,1,81) : T]" |
In response to Teh Governator
|
|
Teh Governator wrote:
Or, a slightly shorter method: > world<<"[src.name]: [length(T)>81 ? copytext(T,1,81) : T]" That snippet doesn't work the same way the PirateHead's does, Governator. It may be shorter, but it doesn't work as it's supposed to. |
In response to PirateHead
|
|
80 characters is kind of an arbitrary choice given that BYOND doesn't use DOS's text mode. It's also a really poor choice because anything worth saying is usually going to be longer than that. A better limit would be 400 or even higher. Most developers have discovered that 256, a more common arbitrary choice, is too low.
Lummox JR |
In response to Lummox JR
|
|
This is the first time I've written a MUD for anything but DOS. However, just to play devil's advocate, I find that once you are typing a few hundred characters the "say" command is less applicable than the "narrate" command.
In any case, to the codesmith in distress, don't let this discussion confuse you. The idea is that you can limit text to any arbitrary amount. Alternately, you can limit it to a number of words or even a number of sentences, depending on the average length of messages to chat. |
In response to DeathAwaitsU
|
|
DeathAwaitsU wrote:
Use length() or lentext(). Don't use lentext(). It's been deprecated in favor of the length() proc, which not only returns the same value that lentext() would on a text string, but can also be used to get the length of other types of data, like savefiles. There is no garuntee that lentext() will even be supported in the future, so it's best to not use it at all. ~X |