ID:160896
 
Ok, I want to make it so, When someone enters their name, I can make the name variable null, and save the name they enter to another variable, so they cant be right clicked to see the name, but when they talk you can see their name. Anyone know the exact way to do that?
You just explained exactly how to do that.
In response to Glarfugus
I get what your saying but, I dont know how to make it so the other variable, will stick with the original input, so the other goes null and it stays, I would try to make one equal t the other but when it goes null the other will go null too.
mob
Login()
var/name=""
var/fname=input("What is your name?")

verb/say(msg as message)
world << "[fname]sez:[msg]"

I really don't understand what you mean.
In response to Giantpandaman
That code won't even compile, mob/name is already defined.
In response to Glarfugus
No, it will compile.
In response to Popisfizzy
Really? I thought there would be a "duplicate definition" compile error.
In response to Jemai1
Only if it's defined multiple times in the same scope.
In response to Popisfizzy
Ah, you're right.
The mouse_opacity var may or may not be suitable for you for this purpose, depending on your game.

Anyway, if the above is unsuitable for you, you can use a workaround for this, although presently there is no very good way to do this. The approach is simple: set the players' names to null (actually, I think setting to a string like " " (space) works better, it has less bad implications), and use a different variable to present their name in dialog and other stuff in the game. Quick example:
mob/player
var/rname //real name
New()
..()
spawn(1) //allow character-creation routines and similar procs a chance to set the name first
rname = name //set the rname to the value of the name
name = " " //and give it no actual name

Of course, you could naturally just do this if you account for your character creation method changes rname instead of name:
mob/player
name = " "
var/rname


And the rest of your game such as Say() verbs will use rname, of course (this means you also can't embed object (player mobs') references directly in text, eg you can't do "you hit [src]", it won't work).
mob/player/verb/Say(msg as text)
viewers(src) << "[src.rname] says: [msg]"
In response to Relleke
Relleke wrote:
I would try to make one equal t the other but when it goes null the other will go null too.

No, it wouldn't, so that works. Setting a variable to another variable doesn't create a constant "relationship" between them or anything like that - they're not effected by eachother.

Setting a var to another var does just that - setting a var's value to the current value of a different var. No more, no less.
In response to Kaioken
So, If I made that var equal to the other, then the first thing that is entered into it will stay? so that would work?
In response to Relleke
Relleke wrote:
So, If I made that var equal to the other, then the first thing that is entered into it will stay?

Yes, like I said. That's how it works. Just 'set X to the [current] value of Y'.
In response to Kaioken
I tried to do what you said to, but every time I use the name variable, the normal one, I keep gettin the duplicate definition error
In response to Relleke
Well, you must have done this wrong. Have you written var/name? That is unneeded, because the 'var' keyword is used to declare new vars, but name is already a built-in variable, and you cannot define a new var that is named the same (neither do you need to). If this is the case, just override the name var's value instead of declaring it (as seen in my example code above).
If this does not fix your problem, then post your code so I am not just guessing.