VV and VV Mass Modify now accept variables when editing a string variable, this allows you to embed variables in string variables, variableception.

This commit is contained in:
Remie Richards
2015-08-10 15:20:15 +01:00
parent fcbd841b60
commit 9ca1f2f262
4 changed files with 171 additions and 12 deletions
+85 -6
View File
@@ -173,38 +173,117 @@
if("text")
var/new_value = input("Enter new text:","Text",O.vars[variable]) as text|null
if(new_value == null) return
var/process_vars = 0
var/unique = 0
if(findtext(new_value,"\["))
process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
if(process_vars == "Yes")
process_vars = 1
unique = alert(usr,"Process vars unique to each instance, or same for all?","Variable Association","Unique","Same")
if(unique == "Unique")
unique = 1
else
unique = 0
else
process_vars = 0
var/pre_processing = new_value
var/list/varsvars = list()
if(process_vars)
varsvars = string2listofvars(new_value, O)
if(varsvars.len)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[O.vars[V]]")
O.vars[variable] = new_value
//Convert the string vars for anything that's not O
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if ( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
new_value = pre_processing //reset new_value, ready to convert it uniquely for the next iteration
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
else
new_value = O.vars[variable] //We already processed the non-unique form for O, reuse it
M.vars[variable] = new_value
else if(istype(O, /obj))
for(var/obj/A in world)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
new_value = pre_processing
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
else
new_value = O.vars[variable]
A.vars[variable] = new_value
else if(istype(O, /turf))
for(var/turf/A in world)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
new_value = pre_processing
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
else
new_value = O.vars[variable]
A.vars[variable] = new_value
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if (M.type == O.type)
M.vars[variable] = O.vars[variable]
new_value = pre_processing
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
else
new_value = O.vars[variable]
M.vars[variable] = new_value
else if(istype(O, /obj))
for(var/obj/A in world)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
new_value = pre_processing
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
else
new_value = O.vars[variable]
A.vars[variable] = new_value
else if(istype(O, /turf))
for(var/turf/A in world)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
new_value = pre_processing
if(process_vars)
if(unique)
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
else
new_value = O.vars[variable]
A.vars[variable] = new_value
if("num")
var/new_value = input("Enter new number:","Num",\
+35 -5
View File
@@ -28,7 +28,7 @@ var/list/VVckey_edit = list("key", "ckey")
src.modify_variables(ticker)
feedback_add_details("admin_verb","ETV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/mod_list_add_ass() //haha
/client/proc/mod_list_add_ass(atom/O) //haha
var/class = "text"
if(src.holder && src.holder.marked_datum)
@@ -74,6 +74,14 @@ var/list/VVckey_edit = list("key", "ckey")
if(!var_value) return
if(istext(var_value))
if(findtext(var_value,"\["))
var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
if(process_vars == "Yes")
var/list/varsvars = string2listofvars(var_value, O)
for(var/V in varsvars)
var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]")
return var_value
@@ -123,12 +131,18 @@ var/list/VVckey_edit = list("key", "ckey")
if(!var_value) return
if(istext(var_value))
if(findtext(var_value,"\["))
var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
if(process_vars == "Yes")
var/list/varsvars = string2listofvars(var_value, O)
for(var/V in varsvars)
var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]")
L += var_value
switch(alert("Would you like to associate a var with the list entry?",,"Yes","No"))
if("Yes")
L += var_value
L[var_value] = mod_list_add_ass() //haha
if("No")
L += var_value
L[var_value] = mod_list_add_ass(O) //haha
world.log << "### ListVarEdit by [src]: [O.type] [objectvar]: ADDED=[var_value]"
log_admin("[key_name(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]")
message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]")
@@ -289,6 +303,14 @@ var/list/VVckey_edit = list("key", "ckey")
if("text")
new_var = input("Enter new text:","Text") as text
if(findtext(new_var,"\["))
var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
if(process_vars == "Yes")
var/list/varsvars = string2listofvars(new_var, O)
for(var/V in varsvars)
new_var = replacetext(new_var,"\[[V]]","[O.vars[V]]")
if(assoc)
L[assoc_key] = new_var
else
@@ -537,6 +559,14 @@ var/list/VVckey_edit = list("key", "ckey")
if("text")
var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|text
if(var_new==null) return
if(findtext(var_new,"\["))
var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
if(process_vars == "Yes")
var/list/varsvars = string2listofvars(var_new, O)
for(var/V in varsvars)
var_new = replacetext(var_new,"\[[V]]","[O.vars[V]]")
O.vars[variable] = var_new
if("num")