ID:142334
 
Code:
/mob/proc/Edit(var/mob/M as mob in view(5))
var/L = list("strength","endurance","agility","power","shield","offense","stamina","defense","vitality","stability","recorvery")
var/mob/E = input("Edit Variable", "Edit a variable") in L
M.E = input("What Value?","What Value?") as num


Problem description:

Edit Mob vars won't work.
Please help.
Firstly, don't use spaces as a the whitespace for organization. It's best to use tabs or four-or-so spaces.

To edit a mob's variables, you're going to have to use the vars list, which is on all /atoms.
It seems like you're very much a beginner. This kind of verb is too complex for one, and you have quite a few errors/misconceptions in your attempt here. It would be best to leave this for later after you are more versed and acquainted in the language. You can start that by reading here. Good luck!
In response to Popisfizzy
How would i use it?
Is a list of vars in M.vars?
In response to Lcooper
Yes, hence the name. The element in the list is the variable name, and the associated value is the value of the variable.
In response to Popisfizzy
/mob/proc/Edit(var/mob/M as mob in world)
var/E
E = input("Pick","Pick",E) in M.vars
M.E = input("Pick","Pick",M.E) as num

This is my revised code.
I get a undifined var error.
In response to Lcooper
If you didn't ignore my post, you'd come to a page with several useful links you should (or may I say, need) visit. Among them is a link to the DM Reference, which documents a lot of things about the DM language, including built-in procs and variables. It is a resource that should be consulted very often when programming, especially when beginning (but not limited to), it's also available from within Dream Maker itself by pressing F1.
In response to Kaioken
I have been using it.
In response to Lcooper
You should have also used it instead of asking about the 'vars' var, then. It documents it as well.

Missed your other post-

Lcooper wrote:
/mob/proc/Edit(var/mob/M as mob in world)
var/E
E = input("Pick","Pick",E) in list(M.vars)
usr << E

This is my revised code.
No errors occur but a prompt doesn't come up.

This is because proc arguments are different from verb arguments. Using the 'as' keyword and as such have no effect in procs, unless they're used as verbs. If you're keeping this a proc, you're going to need to manually use input() to retrieve a value for the arguments. Also, in your existing input(), you're using usr as the target (the player to ask), as it is the default value and you haven't specified another. This is bad; usr is unsafe to use in procs. Lastly, your usage of the 3rd input() argument is useless, since E is null (you don't have to use extra args if you don't need to, null is used automatically if you don't).
In response to Kaioken
I'm adding this proc to the admins panel.
So it is a verb in a way.
and usr << E is just to debug.
In response to Lcooper
Lcooper wrote:
I'm adding this proc to the admins panel.

Do you mean you're adding it to the verbs list? If so, then it should definitely at least show a prompt for choosing a mob. I guess that prompt does work properly but simply doesn't show up because you're the only mob in the world, so there is nothing to choose from. Your input() call probably won't even show up, yes, since the only choice you're giving is a list, and input() doesn't handle that (apparently you're unaware you're using a list inside another list, which is unneeded). Just use the vars list as the choices list (after 'in'), instead of using the list() proc to create another list.

and usr << E is just to debug.

I was referring to the argument of course. Meaning, the use of E in the input() line.
In response to Kaioken
yes, i di mean that.
Can you tell me how to put the user input into M.E?
Because I know why it won't work. Its just i don't know
how to...you know.
In response to Lcooper
Lcooper wrote:
Can you tell me how to put the user input into M.E?

The . operator only accepts a var name (or a proc name) on its right side. You can't use another variable there, or anything else. But Popsisfizzy already explained you need to use the vars list in order to dynamically change a variable using a string that contains the variable's name. The DM Reference explains how to do this. Setting the associated value of the var-name in the list will cause the variable itself to change.
In response to Kaioken
Ok, thanks guys for al your help. I fixed it.
Thanks again.