I'm sure everyone knows how the DM language adds the word "The" in front of any defined name variable text if the first letter isn't a capital letter.
Is there a way to override that built in DM thing? If not, how would I make my "create name" input() proc to check the first letter of the name they type in, if it's a capital or not?
ID:272691
Dec 5 2008, 10:11 am
|
|
Dec 5 2008, 10:16 am
|
|
The \proper or \improper text macro:
|
Look up copytext() and text2ascii().
mob/verb/name_change() copytext() copies the letters between its 2nd and 3rd arg. Note that the number in the third arg is like a stopping point, it isn't included in the text, but the second arg is included in the text. text2ascii() converts text to an ASCII value, and the capital letters in ASCII happen to be between 65 and 90. |
In response to Jeff8500
|
|
Or you can just capitalize it using uppertext() o_O
|
In response to Andre-g1
|
|
But what if they try naming themselves an improper noun, and they realize they can't do that? :P. I thought about that, but he asked how to check, not how to change.
|
In response to Xooxer
|
|
The \improper text macro adds "the" in front of the name regardless if it's capitalized or not.
|
In response to Mizukouken Ketsu
|
|
So I'll use \proper >_> rofl
|
In response to Jeff8500
|
|
Well, that code certainly doesn't compile for me.
if(!T) return -> variables are case sensitive sir. if(text2ascii(copytext(t,1,2)) in 65 to 90) -> An interesting through, but my compiler says: error::invalid expression Also there's a logic error, you never placed in ! operator in that if statement. So if it had worked, it would have asked people for a capital letter regardless if they had one. Also, your ASCII values are a little off. A -> 65 Z -> 90 a -> 97 z -> 122 But following your idea: mob But there are infinite better ways to handle this. |
In response to Tiberath
|
|
Woops, those were some stupid mistakes!
if(text2ascii(copytext(t,1,2)) in 65 to 90) -> An interesting through, but my compiler says: error::invalid expression I heard that would work as short hand outside of switch, looks like I either remembered incorrectly, etc. if(!T) return -> variables are case sensitive sir. I should have just made it T, I usually name my one letter variables capital letters, so I make that mistake occasionally. Also, on the ASCII thing, I meant to put a ! in that if(), too! Though you're right, it would create slightly less overhead if you check if it's between 97 and 122. |
In situations when you want to ensure the name displays literally, you can simply embed the name variable instead of the actual object reference. For instance:
mob Code intended for demonstration only. I am not liable for any consequences or side effects from use. Pulverizing of old men unrecommended. |
In response to Jeff8500
|
|
Relax, we all have our bad days. =)
There have been occasions where I've seen syntax's for if() statements and the like that I didn't know were possible. I generally forget about them as well. |
In response to Tiberath
|
|
Same here; and actually, the syntax he used exists! :P
It's probably confused by proc(s) for one reason or another. =\ Dunno if it's worthwhile to report. This works, AFAIK: var/MyNum = rand(1,100) //or text2ascii()... |
In response to Kaioken
|
|
These all compile and run fine for me:
var/i=rand(1,10) I'm not sure what was causing Tiberath's error. |