ID:142453
 
Code:
mob proc Create_New_Character() var = input(src,"What would you like to name this character? (Limited to 24 characters.)src.key) as text

Login.dm:6:error: missing left-hand argument to =.
Problem description:
When I compile my game, this is my first and I just learned to code, so how do I fix this? And what does it mean? I tried using something called kaname or something and it said it wasn't used.
You have the name the variable, like so:
var/variable

In response to Kakashi24142
mob
proc
Create_New_Character()
var/nameofcharacter = input(src,"What would you like to name this character? (Limited to 24 characters.)[src.key]") as text
H1ppyh8t3r64 wrote:
Code:
<code></code>

Login.dm:6:error: missing left-hand argument to =.
Problem description:
When I compile my game, this is my first and I just learned to code, so how do I fix this? And what does it mean? I tried using something called kaname or something and it said it wasn't used.

When posting code on the forums, use the DM tag. It will parse the code to look just like the DM Compiler.

mob
proc
Create_New_Character()
var = input(src,"What would you like to name this character? (Limited to 24 characters.)src.key) as text


There are a few things wrong with this.

For starters, you haven't defined a variable for the input to assign a value to. This must be done. That is the cause of your "missing left hand argument to =". It means, you don't have anything to the left of your equals sign.

The other two have covered how to do that. var/someword.

So now you have:
mob
proc
Create_New_Character()
var/MyName = input(src,"What would you like to name this character? (Limited to 24 characters.)src.key) as text


Okay, there is still a few things left wrong with this. The next and most important one is closing that string. At the moment you have opened a string inside the input() proc, but you haven't closed it. We are going to do this now.

mob
proc
Create_New_Character()
var/MyName = input(src,"What would you like to name this character? (Limited to 24 characters.)src.key") as text


Okay. The string is closed and it's now able to be compiled. But you still have a couple more problems.

I see you're using src.key there. I assume that you don't want that to be art of the message in the box, or it's title. You want that to be the default value of the input box, correct?

Well, when you're using input(), the arguments are listed as such: input(target, text, title, default_value). At the moment, your target is set to src and your text is set to "What would you like to name this character? (Limited to 24 characters.)src.key". In order to do as I think you want, you'll have to change it to this:

input(src, "What would you like to name this character? (Limited to 24 characters)", "Character Name", src.key) as text
.

If you see there, I've named the input box "Character Name" and given it the default value of src.key. Because src.key is a variable, and we don't have any extra text accompaning, it wasn't necessary to encase it in quotation marks. If you were to encase it in quotation marks, you'd have to do it like this: "[src.key]". The square braces tell the compiler "I'm a variable, put my value here".

So to complete you're code, you'd want it looking something like this:
mob
proc
Create_New_Character()
var/MyName = input(src,"What would you like to name this character? (Limited to 24 characters.)", "Character Name", src.key) as text


Now as you said, when you tried to use it, you received the warning "variable defined but not used". Note: This is a warning, not an error. This is just the compiler asking: "You've defined a variable, but you're not using it, so why define it in the first place?".

To get rid of this warning, it's just a matter of using the variable. For instance, setting the users name to the vale they gave via src.name = MyName.

The complete script would be:
mob
proc
Create_New_Character()
var/MyName = input(src,"What would you like to name this character? (Limited to 24 characters.)", "Character Name", src.key) as text
src.name = MyName


Please make sure you've read the entire post and not just skipped to the end for the final bit of working code. Doing that will just make me bitter and rob me of motivation to help others.

In response to Tiberath
Thanks, and yes, I did read the whole post. But I don't see any different when you closed the proc, just different colors at the end.
In response to H1ppyh8t3r64
H1ppyh8t3r64 wrote:
Thanks, and yes, I did read the whole post. But I don't see any different when you closed the proc.

What do you mean "close the proc"?
In response to Tiberath
I mean string.

Okay, there is still a few things left wrong with this. The next and most important one is closing that string. At the moment you have opened a string inside the input() proc, but you haven't closed it. We are going to do this now.
In response to H1ppyh8t3r64
H1ppyh8t3r64 wrote:
I mean string.

Okay, there is still a few things left wrong with this. The next and most important one is closing that string. At the moment you have opened a string inside the input() proc, but you haven't closed it. We are going to do this now.

If you mean you didn't see a compile time error with it: Don't cite me on this, but from what I can gather, the first major compile time error the compiler finds, it'll stop compiling there and tell you of it. Then when you fix and recompile, it'll tell you of the next one.

Had you not missed the equals sign, you would have received an error something along the lines of:
loading omg.dme
omg.dm:4: unterminated text (expecting ")
omg.dm:5:error: src: missing comma ',' or right-paren ')'
omg.dm:5:error: src: expected end of statement

omg.dmb - 3 errors, 0 warnings (double-click on an error to jump to it)
In response to Tiberath
I didn't get any of those errors. It said loading....(blah)
missing argument (blah)
0 errors, 1 warning. But after I used the code u gave, I got it now, thanks. But, I didn't get those errors. I used the EXACT code that I showed in my first post, so, did I do something bad, good, wrong?
In response to H1ppyh8t3r64
As I said, the code in your original post already had a compile-time error, you were missing an equals sign (as the post title suggests). Once you had fixed that, you would have had the errors I mentioned about. But chances are you would have either copied the other two or mine directly instead of physically making the changes yourself.

That's why you didn't receive those errors. Worry not, everything is working as it should.
In response to Tiberath
What are compile-time errors? I don't get coding very well. I read Zilaz or something like that, his Tutorial twice. and I am having trouble. Does BYOND have a page that can teach you about vars/procs and other things like that? Or is that you?
In response to H1ppyh8t3r64
H1ppyh8t3r64 wrote:
What are compile-time errors? I don't get coding very well. I read Zilaz or something like that, his Tutorial twice. and I am having trouble. Does BYOND have a page that can teach you about vars/procs and other things like that? Or is that you?

Compile-time errors are errors that appear in the box down the bottom. Errors you have to fix before you can compile and run the game.

Run-time errors are errors that appear when you are playing the game. Where code that works in the compiler, but logically is broken is executed. Generally you get those errors in Options and Messages.

As for a page where you can learn about that kind of thing. The Bwicki had useful information about runtimes and compiletimes, but it's been trashed.

You could probably find an article or two on the Dream Makers tutorials pages.

A guide to Runtime errors. I couldn't find one for compile time errors I'm sorry. But I'm a bit busy at the moment to look. Give Dream Makers a look and see what you can come up with. Lot of good stuff there.
In response to H1ppyh8t3r64