ID:262056
 
When I use this procedure, the line I point out (<--) is supposed to copy the variable.
    edit_list(list/L)
var/list/new_list = list()
for(var/item in L)
new_list += "[item]"+"[L[item]]"
new_list["[item]"+"[L[item]]"] = L[item] <---
world << "[item] --> [new_list[item]]"
world << "[item] --> [L[item]]"
return new_list


Sure it copies the variable, but it doesn't copy the actual var saved.

Example, if an item in L was "Strength" and it's value was "src.str" in another procedure, this procedure saves the actual number, not the actual variable.

Is there any way to let it save the variable?

~~> Dragon Lord
Unknown Person wrote:
When I use this procedure, the line I point out (<--) is supposed to copy the variable.
>   edit_list(list/L)
> var/list/new_list = list()
> for(var/item in L)
> new_list += "[item]"+"[L[item]]"
> new_list["[item]"+"[L[item]]"] = L[item] <---
> world << "[item] --> [new_list[item]]"
> world << "[item] --> [L[item]]"
> return new_list
>

Sure it copies the variable, but it doesn't copy the actual var saved.

Example, if an item in L was "Strength" and it's value was "src.str" in another procedure, this procedure saves the actual number, not the actual variable.

Is there any way to let it save the variable?

~~> Dragon Lord

Instead of L[item], does just item work?
Unknown Person wrote:
When I use this procedure, the line I point out (<--) is supposed to copy the variable.
>   edit_list(list/L)
> var/list/new_list = list()
> for(var/item in L)
> new_list += "[item]"+"[L[item]]"
> new_list["[item]"+"[L[item]]"] = L[item] <---
> world << "[item] --> [new_list[item]]"
> world << "[item] --> [L[item]]"
> return new_list
>

Sure it copies the variable, but it doesn't copy the actual var saved.

Example, if an item in L was "Strength" and it's value was "src.str" in another procedure, this procedure saves the actual number, not the actual variable.

Is there any way to let it save the variable?

What you said makes absolutely no sense. Can you clarify--a lot?

Meanwhile I can point out that this is absolutely redundant:
new_list += "[item]"+"[L[item]]"
new_list["[item]"+"[L[item]]"] = L[item]
The first line is useless because the second line would add that item to the list anyway.</dm>
Lummox JR
In response to Lummox JR
Lummox JR wrote:
What you said makes absolutely no sense. Can you clarify--a lot?

Meanwhile I can point out that this is absolutely redundant:
new_list += "[item]"+"[L[item]]"
> new_list["[item]"+"[L[item]]"] = L[item]
The first line is useless because the second line would add that item to the list anyway.</dm>
Lummox JR

Alright, I'll explain it in steps:

In the old list, it is like
var/list/L = list("Strength: "=src.str,"Defense: "=src.def) etc...
var/A = input("Pick","Blah") in L

In the same procedure, you could add src.str, vit, or whatever without finding any variables.
EG:
L[A] ++

when I use "edit_list()", it creates a new list.

In that prodecure, I am trying to duplicate list[item] into new_list[item]. It works, but it doesn't take the actual variable into it. It takes the number value.

So I'm asking, is there a way to take the variable?

I'm thinking on the lines of making a new argument with the owner of the variables and relating them.

~~> Dragon Lord
In response to Jon88
"item" would be the actual text you see when selecting it.

L[item] would be the value.

I'm trying to search for the variable L[item] actually is.

~~> Dragon Lord
In response to Unknown Person
You would have to use a text reference. L["str"] = src.str does not actually save a direct reference to the variable. It saves the value. Thus, if src.str was 10, then L["str"] = 10.
Should you change src.str to 20 later, L["str"] will still = 10.

To get the variable itself, you'd have to use a text reference to the variable name, such as L["str"] = "src.src". You would then have to pull the current value out of the vars list by using src.vars[L["str"]]. It is a very tedious and redundant process, although I can see some uses for it (and have made use of several of them).
In response to Unknown Person
Unknown Person wrote:
Alright, I'll explain it in steps:

In the old list, it is like
var/list/L = list("Strength: "=src.str,"Defense: "=src.def) etc...
var/A = input("Pick","Blah") in L

In the same procedure, you could add src.str, vit, or whatever without finding any variables.

Nope, this doesn't clarify at all. Your terminology is entirely wrong. "Finding" is a meaningless word in this context, so what you just said is nonsensical.

In that prodecure, I am trying to duplicate list[item] into new_list[item]. It works, but it doesn't take the actual variable into it. It takes the number value.

So I'm asking, is there a way to take the variable?

If you mean some sort of reference to the variable so you can modify it later, the only way to do that is to send the name of the var, and use the vars list to modify the var when you're ready.

Lummox JR