Fixes editing associative lists

This commit is contained in:
AnturK
2015-05-24 14:56:11 +02:00
parent 46f2721cdf
commit 2638a5d4e9
+63 -13
View File
@@ -142,15 +142,33 @@ var/list/VVckey_edit = list("key", "ckey")
if(confirm != "Continue")
return
var/list/names = sortList(L)
var/assoc = 0
if(L.len > 0)
var/a = L[1]
if(L[a] != null)
assoc = 1 //This is pretty weak test but i can't think of anything else
usr << "List appears to be associative."
var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
var/list/names = null
if(!assoc)
names = sortList(L)
var/variable
var/assoc_key
if(assoc)
variable = input("Which var?","Var") as null|anything in L + "(ADD VAR)"
else
variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
if(variable == "(ADD VAR)")
mod_list_add(L, O, original_name, objectvar)
return
if(!variable)
if(assoc)
assoc_key = variable
variable = L[assoc_key]
if(!assoc && !variable || assoc && !assoc_key)
return
var/default
@@ -240,7 +258,12 @@ var/list/VVckey_edit = list("key", "ckey")
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
class = "marked datum"
var/original_var = L[L.Find(variable)]
var/original_var
if(assoc)
original_var = L[assoc_key]
else
original_var = L[L.Find(variable)]
var/new_var
switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet.
@@ -249,7 +272,10 @@ var/list/VVckey_edit = list("key", "ckey")
if("restore to default")
new_var = initial(variable)
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("edit referenced object")
modify_variables(variable)
@@ -263,35 +289,59 @@ var/list/VVckey_edit = list("key", "ckey")
if("text")
new_var = input("Enter new text:","Text") as text
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("num")
new_var = input("Enter new number:","Num") as num
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("type")
new_var = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("reference")
new_var = input("Select reference:","Reference") as mob|obj|turf|area in world
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("mob reference")
new_var = input("Select reference:","Reference") as mob in world
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("file")
new_var = input("Pick file:","File") as file
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("icon")
new_var = input("Pick icon:","Icon") as icon
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
if("marked datum")
new_var = holder.marked_datum
L[L.Find(variable)] = new_var
if(assoc)
L[assoc_key] = new_var
else
L[L.Find(variable)] = new_var
world.log << "### ListVarEdit by [src]: [O.type] [objectvar]: [original_var]=[new_var]"
log_admin("[key_name(src)] modified [original_name]'s [objectvar]: [original_var]=[new_var]")