mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Varedit refactor
This commit is contained in:
@@ -139,6 +139,8 @@
|
|||||||
|
|
||||||
#define iswindow(A) (istype(A, /obj/structure/window))
|
#define iswindow(A) (istype(A, /obj/structure/window))
|
||||||
|
|
||||||
|
#define isdatum(A) (istype(A, /datum))
|
||||||
|
|
||||||
#define isclient(A) (istype(A, /client))
|
#define isclient(A) (istype(A, /client))
|
||||||
|
|
||||||
#define isatom(A) (istype(A, /atom))
|
#define isatom(A) (istype(A, /atom))
|
||||||
|
|||||||
@@ -121,6 +121,11 @@
|
|||||||
for(var/key in pooledvariables[type])
|
for(var/key in pooledvariables[type])
|
||||||
vars[key] = pooledvariables[type][key]
|
vars[key] = pooledvariables[type][key]
|
||||||
|
|
||||||
|
//Called when a variable is edited by admin powers
|
||||||
|
//Return 1 to block the varedit!
|
||||||
|
/datum/proc/variable_edited(variable_name, old_value, new_value)
|
||||||
|
return
|
||||||
|
|
||||||
/proc/isInTypes(atom/Object, types)
|
/proc/isInTypes(atom/Object, types)
|
||||||
if(!Object)
|
if(!Object)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -1,3 +1,58 @@
|
|||||||
|
var/global/list/matching_type_list_cache = list()
|
||||||
|
|
||||||
|
/proc/matching_type_list(object, parent_type = /atom)
|
||||||
|
//Key string for the cache
|
||||||
|
var/key = "[object]:[parent_type]"
|
||||||
|
//Get cached list's copy if it exists
|
||||||
|
var/list/cache = matching_type_list_cache[key]
|
||||||
|
if(cache)
|
||||||
|
return cache.Copy()
|
||||||
|
|
||||||
|
var/list/matches = list()
|
||||||
|
//The string is null or "" - no need for calculations
|
||||||
|
if(!object || !length(object))
|
||||||
|
return typesof(parent_type)
|
||||||
|
|
||||||
|
if(text_ends_with(object, ".")) //Path ends with a dot - DO NOT include subtypes
|
||||||
|
object = copytext(object, 1, length(object)) //Remove the dot
|
||||||
|
|
||||||
|
for(var/path in typesof(parent_type))
|
||||||
|
if(text_ends_with("[path]", object))
|
||||||
|
matches += path
|
||||||
|
else //Include subtypes
|
||||||
|
for(var/path in typesof(/atom))
|
||||||
|
if(findtext("[path]", object))
|
||||||
|
matches += path
|
||||||
|
|
||||||
|
matching_type_list_cache[key] = matches.Copy()
|
||||||
|
|
||||||
|
return matches
|
||||||
|
|
||||||
|
var/global/list/get_vars_from_type_cache = list()
|
||||||
|
|
||||||
|
/proc/get_vars_from_type(T)
|
||||||
|
if(ispath(T, /atom) && !ispath(T, /atom/movable))
|
||||||
|
//It's impossible to spawn a turf or an area without a location
|
||||||
|
//Attempting to proceed will result in a runtime error
|
||||||
|
return null
|
||||||
|
|
||||||
|
var/list/cache = get_vars_from_type_cache[T]
|
||||||
|
if(cache)
|
||||||
|
return cache.Copy()
|
||||||
|
|
||||||
|
var/list/variable_list = list()
|
||||||
|
|
||||||
|
var/datum/temp_datum = new T(null)
|
||||||
|
|
||||||
|
for(var/variable in temp_datum.vars)
|
||||||
|
variable_list.Add(variable)
|
||||||
|
variable_list = sortList(variable_list) //Sort the variable list alphabetically
|
||||||
|
get_vars_from_type_cache[T] = variable_list
|
||||||
|
|
||||||
|
qdel(temp_datum)
|
||||||
|
|
||||||
|
return variable_list
|
||||||
|
|
||||||
var/global/list/existing_typesof_cache = list()
|
var/global/list/existing_typesof_cache = list()
|
||||||
|
|
||||||
//existing_typesof functions like typesof, with some differences
|
//existing_typesof functions like typesof, with some differences
|
||||||
|
|||||||
@@ -321,7 +321,7 @@
|
|||||||
<b>C</b> - Change, asks you for the var type first.<br>
|
<b>C</b> - Change, asks you for the var type first.<br>
|
||||||
<b>M</b> - Mass modify: changes this variable for all objects of this type.</font><br>
|
<b>M</b> - Mass modify: changes this variable for all objects of this type.</font><br>
|
||||||
<hr><table width='100%'><tr><td width='20%'><div align='center'><b>Search:</b></div></td><td width='80%'><input type='text' id='filter' name='filter_text' value='' style='width:100%;'></td></tr></table><hr>
|
<hr><table width='100%'><tr><td width='20%'><div align='center'><b>Search:</b></div></td><td width='80%'><input type='text' id='filter' name='filter_text' value='' style='width:100%;'></td></tr></table><hr>
|
||||||
<ol id='vars'>"}
|
<ul id='vars'>"}
|
||||||
var/list/names = list()
|
var/list/names = list()
|
||||||
for (var/V in D.vars)
|
for (var/V in D.vars)
|
||||||
names += V
|
names += V
|
||||||
@@ -331,7 +331,7 @@
|
|||||||
for (var/V in names)
|
for (var/V in names)
|
||||||
body += debug_variable(V, D.vars[V], 0, D)
|
body += debug_variable(V, D.vars[V], 0, D)
|
||||||
|
|
||||||
body += "</ol>"
|
body += "</ul>"
|
||||||
body = jointext(body,"")
|
body = jointext(body,"")
|
||||||
|
|
||||||
var/html = "<html><head>"
|
var/html = "<html><head>"
|
||||||
@@ -369,7 +369,12 @@ body
|
|||||||
var/html = ""
|
var/html = ""
|
||||||
|
|
||||||
if(DA)
|
if(DA)
|
||||||
html += "<li style='backgroundColor:white'>(<a href='?_src_=vars;datumedit=\ref[DA];varnameedit=[name]'>E</a>) (<a href='?_src_=vars;datumchange=\ref[DA];varnamechange=[name]'>C</a>) (<a href='?_src_=vars;datummass=\ref[DA];varnamemass=[name]'>M</a>) "
|
html += {"
|
||||||
|
<li style='backgroundColor:white'>
|
||||||
|
(<a href='?_src_=vars;datumedit=\ref[DA];varnameedit=[name]'>E</a>)
|
||||||
|
(<a href='?_src_=vars;datumchange=\ref[DA];varnamechange=[name]'>C</a>)
|
||||||
|
(<a href='?_src_=vars;datummass=\ref[DA];varnamemass=[name]'>M</a>)
|
||||||
|
(<a href='?_src_=vars;datumsave=\ref[DA];varnamesave=[name]'>S</a>) "}
|
||||||
else
|
else
|
||||||
html += "<li>"
|
html += "<li>"
|
||||||
|
|
||||||
@@ -491,8 +496,7 @@ body
|
|||||||
to_chat(usr, "This can only be used on instances of types /client or /datum")
|
to_chat(usr, "This can only be used on instances of types /client or /datum")
|
||||||
return
|
return
|
||||||
|
|
||||||
modify_variables(D, href_list["varnameedit"], 1)
|
variable_set(src, D, href_list["varnameedit"], TRUE)
|
||||||
|
|
||||||
else if(href_list["togbit"])
|
else if(href_list["togbit"])
|
||||||
if(!check_rights(R_VAREDIT))
|
if(!check_rights(R_VAREDIT))
|
||||||
return
|
return
|
||||||
@@ -517,7 +521,7 @@ body
|
|||||||
to_chat(usr, "This can only be used on instances of types /client or /datum")
|
to_chat(usr, "This can only be used on instances of types /client or /datum")
|
||||||
return
|
return
|
||||||
|
|
||||||
modify_variables(D, href_list["varnamechange"], 0)
|
variable_set(src, D, href_list["varnameedit"])
|
||||||
|
|
||||||
else if(href_list["varnamemass"] && href_list["datummass"])
|
else if(href_list["varnamemass"] && href_list["datummass"])
|
||||||
if(!check_rights(R_VAREDIT))
|
if(!check_rights(R_VAREDIT))
|
||||||
@@ -528,7 +532,18 @@ body
|
|||||||
to_chat(usr, "This can only be used on instances of type /atom")
|
to_chat(usr, "This can only be used on instances of type /atom")
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd_mass_modify_object_variables(A, href_list["varnamemass"])
|
cmd_mass_modify_object_variables(A.type, href_list["varnamemass"])
|
||||||
|
else if(href_list["varnamesave"] && href_list["datumsave"])
|
||||||
|
if(!check_rights(R_VAREDIT))
|
||||||
|
return
|
||||||
|
|
||||||
|
var/atom/A = locate(href_list["datumsave"])
|
||||||
|
|
||||||
|
if(A)
|
||||||
|
var/saved_value = A.vars[href_list["varnamesave"]]
|
||||||
|
|
||||||
|
holder.marked_datum = saved_value
|
||||||
|
to_chat(usr, "Your marked datum is now: [holder.marked_datum]")
|
||||||
|
|
||||||
else if(href_list["mob_player_panel"])
|
else if(href_list["mob_player_panel"])
|
||||||
if(!check_rights(0))
|
if(!check_rights(0))
|
||||||
|
|||||||
@@ -61,6 +61,19 @@ var/global/list/ghdel_profiling = list()
|
|||||||
/atom/proc/handle_beams()
|
/atom/proc/handle_beams()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
/atom/variable_edited(variable_name, old_value, new_value)
|
||||||
|
.=..()
|
||||||
|
|
||||||
|
switch(variable_name)
|
||||||
|
if("light_color")
|
||||||
|
set_light(l_color = new_value)
|
||||||
|
return 1
|
||||||
|
if("light_range")
|
||||||
|
set_light(new_value)
|
||||||
|
return 1
|
||||||
|
if("light_power")
|
||||||
|
set_light(l_power = new_value)
|
||||||
|
|
||||||
/atom/proc/shake(var/xy, var/intensity, mob/user) //Zth. SHAKE IT. Vending machines' kick uses this
|
/atom/proc/shake(var/xy, var/intensity, mob/user) //Zth. SHAKE IT. Vending machines' kick uses this
|
||||||
var/old_pixel_x = pixel_x
|
var/old_pixel_x = pixel_x
|
||||||
var/old_pixel_y = pixel_y
|
var/old_pixel_y = pixel_y
|
||||||
|
|||||||
@@ -1279,19 +1279,7 @@ var/global/floorIsLava = 0
|
|||||||
if(!check_rights(R_SPAWN))
|
if(!check_rights(R_SPAWN))
|
||||||
return
|
return
|
||||||
|
|
||||||
var/list/matches = new()
|
var/list/matches = matching_type_list(object, /atom)
|
||||||
|
|
||||||
if(text_ends_with(object, ".")) //Path ends with a dot - DO NOT include subtypes
|
|
||||||
object = copytext(object, 1, length(object)) //Remove the dot
|
|
||||||
|
|
||||||
for(var/path in typesof(/atom))
|
|
||||||
if(text_ends_with("[path]", object))
|
|
||||||
matches += path
|
|
||||||
else //Include subtypes
|
|
||||||
for(var/path in typesof(/atom))
|
|
||||||
if(findtext("[path]", object))
|
|
||||||
matches += path
|
|
||||||
|
|
||||||
|
|
||||||
if(matches.len==0)
|
if(matches.len==0)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -190,7 +190,8 @@ var/list/admin_verbs_debug = list(
|
|||||||
/client/proc/cmd_admin_find_bad_blood_tracks,
|
/client/proc/cmd_admin_find_bad_blood_tracks,
|
||||||
/client/proc/debugNatureMapGenerator,
|
/client/proc/debugNatureMapGenerator,
|
||||||
/client/proc/callatomproc,
|
/client/proc/callatomproc,
|
||||||
/client/proc/view_runtimes
|
/client/proc/view_runtimes,
|
||||||
|
/client/proc/cmd_mass_modify_object_variables,
|
||||||
)
|
)
|
||||||
var/list/admin_verbs_possess = list(
|
var/list/admin_verbs_possess = list(
|
||||||
/proc/possess,
|
/proc/possess,
|
||||||
|
|||||||
@@ -82,50 +82,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
|
|||||||
|
|
||||||
var/i
|
var/i
|
||||||
for(i = 1, i < argnum + 1, i++) // Lists indexed from 1 forwards in byond
|
for(i = 1, i < argnum + 1, i++) // Lists indexed from 1 forwards in byond
|
||||||
|
lst[i] = variable_set(src)
|
||||||
// Make a list with each index containing one variable, to be given to the proc
|
|
||||||
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area", holder.marked_datum ? "marked datum ([holder.marked_datum.type])" : null, "CANCEL")
|
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
|
||||||
class = "marked_datum"
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
if("CANCEL")
|
|
||||||
return
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
lst[i] = input("Enter new text:","Text",null) as text
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
lst[i] = input("Enter new number:","Num",0) as num
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
lst[i] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
lst[i] = input("Select reference:","Reference",src) as mob|obj|turf|area in world
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
lst[i] = input("Select reference:","Reference",usr) as mob in world
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
lst[i] = input("Pick file:","File") as file
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
lst[i] = input("Pick icon:","Icon") as icon
|
|
||||||
|
|
||||||
if("client")
|
|
||||||
var/list/keys = list()
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
keys += M.client
|
|
||||||
lst[i] = input("Please, select a player!", "Selection", null, null) as null|anything in keys
|
|
||||||
|
|
||||||
if("mob's area")
|
|
||||||
var/mob/temp = input("Select mob", "Selection", usr) as mob in world
|
|
||||||
lst[i] = temp.loc
|
|
||||||
|
|
||||||
if("marked_datum")
|
|
||||||
lst[i] = holder.marked_datum
|
|
||||||
|
|
||||||
if(targetselected)
|
if(targetselected)
|
||||||
if(!target)
|
if(!target)
|
||||||
@@ -153,7 +110,6 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
|
|||||||
var/lst[] // List reference
|
var/lst[] // List reference
|
||||||
lst = new/list() // Make the list
|
lst = new/list() // Make the list
|
||||||
var/returnval = null
|
var/returnval = null
|
||||||
var/class = null
|
|
||||||
|
|
||||||
var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null
|
var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null
|
||||||
if(!procname)
|
if(!procname)
|
||||||
@@ -173,50 +129,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
|
|||||||
|
|
||||||
var/i
|
var/i
|
||||||
for(i = 1, i < argnum + 1, i++) // Lists indexed from 1 forwards in byond
|
for(i = 1, i < argnum + 1, i++) // Lists indexed from 1 forwards in byond
|
||||||
|
lst[i] = variable_set(src)
|
||||||
// Make a list with each index containing one variable, to be given to the proc
|
|
||||||
class = input("What kind of variable?","Variable Type") in list("text", "num", "type", "reference", "mob reference", "icon", "file", "client", "mob's area", holder.marked_datum ? "marked datum ([holder.marked_datum.type])" : null, "CANCEL")
|
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
|
||||||
class = "marked_datum"
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
if("CANCEL")
|
|
||||||
return
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
lst[i] = input("Enter new text:","Text",null) as text
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
lst[i] = input("Enter new number:","Num",0) as num
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
lst[i] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
lst[i] = input("Select reference:","Reference",src) as mob|obj|turf|area in world
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
lst[i] = input("Select reference:","Reference",usr) as mob in world
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
lst[i] = input("Pick file:","File") as file
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
lst[i] = input("Pick icon:","Icon") as icon
|
|
||||||
|
|
||||||
if("client")
|
|
||||||
var/list/keys = list()
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
keys += M.client
|
|
||||||
lst[i] = input("Please, select a player!", "Selection", null, null) as null|anything in keys
|
|
||||||
|
|
||||||
if("mob's area")
|
|
||||||
var/mob/temp = input("Select mob", "Selection", usr) as mob in world
|
|
||||||
lst[i] = temp.loc
|
|
||||||
|
|
||||||
if("marked_datum")
|
|
||||||
lst[i] = holder.marked_datum
|
|
||||||
|
|
||||||
log_admin("[key_name(src)] called [target]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
|
log_admin("[key_name(src)] called [target]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
|
||||||
returnval = call(target,procname)(arglist(lst)) // Pass the lst as an argument list to the proc
|
returnval = call(target,procname)(arglist(lst)) // Pass the lst as an argument list to the proc
|
||||||
@@ -1297,11 +1210,7 @@ client/proc/check_convertables()
|
|||||||
if(!check_rights(R_SPAWN))
|
if(!check_rights(R_SPAWN))
|
||||||
return
|
return
|
||||||
|
|
||||||
var/list/matches[0]
|
var/list/matches = matching_type_list(object, /datum) - typesof(/turf)
|
||||||
|
|
||||||
for(var/path in typesof(/datum) - typesof(/turf))
|
|
||||||
if(findtext("[path]", object))
|
|
||||||
matches += path
|
|
||||||
|
|
||||||
if(matches.len == 0)
|
if(matches.len == 0)
|
||||||
to_chat(usr, "Unable to find any matches.")
|
to_chat(usr, "Unable to find any matches.")
|
||||||
|
|||||||
@@ -1,512 +1,111 @@
|
|||||||
/client/proc/cmd_mass_modify_object_variables(atom/A, var/var_name)
|
/client/proc/cmd_mass_modify_object_variables(target_type as text, variable_name as null|text)
|
||||||
set category = "Debug"
|
set category = "Debug"
|
||||||
set name = "Mass Edit Variables"
|
set name = "Mass Edit Variables"
|
||||||
set desc="(target) Edit all instances of a target item's variables"
|
set desc="(typepath,variable) Change a variable of all objects of the specified type"
|
||||||
|
|
||||||
var/method = 0 //0 means strict type detection while 1 means this type and all subtypes (IE: /obj/item with this set to 1 will set it to ALL itms)
|
|
||||||
|
|
||||||
if(!check_rights(R_VAREDIT))
|
if(!check_rights(R_VAREDIT))
|
||||||
return
|
return
|
||||||
|
|
||||||
if(A && A.type)
|
if(istext(target_type))
|
||||||
if(typesof(A.type))
|
target_type = input("Select an object type to mass-modify", "Mass-editing") as null|anything in matching_type_list(target_type, /atom)
|
||||||
switch(input("Strict object type detection?") as null|anything in list("Strictly this type","This type and subtypes", "Cancel"))
|
|
||||||
|
//get_vars_from_type() fails on turf and area objects. If you want to mass-edit a turf, you have to do it through the varedit window
|
||||||
|
if(ispath(target_type, /atom) && !ispath(target_type, /atom/movable))
|
||||||
|
to_chat(src, "<span class='warning'>It's impossible to perform this task on objects of type [target_type] through the verb. Use the mass edit function from View Variables instead.")
|
||||||
|
if(!target_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
var/include_subtypes = FALSE
|
||||||
|
if(length(typesof(target_type)))
|
||||||
|
switch(alert("Strict object type detection?", "Mass-editing", "Strictly this type","This type and subtypes", "Cancel"))
|
||||||
if("Strictly this type")
|
if("Strictly this type")
|
||||||
method = 0
|
include_subtypes = FALSE
|
||||||
if("This type and subtypes")
|
if("This type and subtypes")
|
||||||
method = 1
|
include_subtypes = TRUE
|
||||||
|
else
|
||||||
|
return
|
||||||
|
|
||||||
|
if(!variable_name)
|
||||||
|
variable_name = input("Select a variable to edit.", "Mass-editing [target_type]") as null|anything in get_vars_from_type(target_type)
|
||||||
|
if(!variable_name)
|
||||||
|
return
|
||||||
|
|
||||||
|
var/reset_to_initial = FALSE
|
||||||
|
var/new_value = null
|
||||||
|
switch(alert("What to do with the object's variable [variable_name]?", "Mass-editing [target_type]", "Reset to initial", "Set new value", "Cancel"))
|
||||||
if("Cancel")
|
if("Cancel")
|
||||||
return
|
return
|
||||||
if(null)
|
if("Reset to initial")
|
||||||
return
|
reset_to_initial = TRUE
|
||||||
|
if("Set new value")
|
||||||
|
new_value = variable_set(usr)
|
||||||
|
|
||||||
|
mass_modify_variable(target_type, variable_name, new_value, reset_to_initial, include_subtypes)
|
||||||
|
|
||||||
src.massmodify_variables(A, var_name, method)
|
|
||||||
feedback_add_details("admin_verb","MEV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
feedback_add_details("admin_verb","MEV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||||
|
log_admin("[key_name(src)] mass modified [target_type]'s [variable_name] to [reset_to_initial ? "its initial value" : " [new_value] "]")
|
||||||
|
message_admins("[key_name_admin(src)] mass modified [target_type]'s [variable_name] to [reset_to_initial ? "its initial value" : " [new_value] "]", 1)
|
||||||
|
|
||||||
|
//Mass-modifies all atoms of type [type], changing their variable [var_name] to [new_value]
|
||||||
|
//If reset_to_initial is TRUE, the variables will be reset to their initial values, instead of getting a new value
|
||||||
|
|
||||||
|
/proc/mass_modify_variable(type, var_name, new_value, reset_to_initial = FALSE, include_subtypes = TRUE)
|
||||||
|
|
||||||
|
var/base_path
|
||||||
|
if(isdatum(type))
|
||||||
|
var/datum/D = type
|
||||||
|
base_path = D.type
|
||||||
|
else if(ispath(type))
|
||||||
|
base_path = type
|
||||||
|
else if(istext(type))
|
||||||
|
base_path = text2path(type)
|
||||||
|
|
||||||
|
if(!ispath(base_path, /atom))
|
||||||
|
to_chat(usr, "Mass-editing is not supported for objects of type [base_path]")
|
||||||
|
|
||||||
|
#define is_valid_atom(atom) (atom.type == base_path || (include_subtypes && istype(atom, base_path)))
|
||||||
|
|
||||||
|
|
||||||
/client/proc/massmodify_variables(var/atom/O, var/var_name = "", var/method = 0)
|
if(ispath(base_path, /turf))
|
||||||
if(!check_rights(R_VAREDIT))
|
|
||||||
return
|
|
||||||
|
|
||||||
var/list/locked = list("vars", "key", "ckey", "client")
|
|
||||||
|
|
||||||
if(holder && !(holder.rights & (R_PERMISSIONS)))
|
|
||||||
for(var/p in forbidden_varedit_object_types)
|
|
||||||
if( istype(O,p) )
|
|
||||||
to_chat(usr, "<span class='warning'>It is forbidden to edit this object's variables.</span>")
|
|
||||||
return
|
|
||||||
|
|
||||||
var/list/names = list()
|
|
||||||
for (var/V in O.vars)
|
|
||||||
names += V
|
|
||||||
|
|
||||||
names = sortList(names)
|
|
||||||
|
|
||||||
var/variable = ""
|
|
||||||
|
|
||||||
if(!var_name)
|
|
||||||
variable = input("Which var?","Var") as null|anything in names
|
|
||||||
else
|
|
||||||
variable = var_name
|
|
||||||
|
|
||||||
if(!variable)
|
|
||||||
return
|
|
||||||
var/default
|
|
||||||
var/var_value = O.vars[variable]
|
|
||||||
var/dir
|
|
||||||
|
|
||||||
if(variable == "holder" || (variable in locked))
|
|
||||||
if(!check_rights(R_DEBUG))
|
|
||||||
return
|
|
||||||
|
|
||||||
if(isnull(var_value))
|
|
||||||
to_chat(usr, "Unable to determine variable type.")
|
|
||||||
|
|
||||||
else if(isnum(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>NUM</b>.")
|
|
||||||
default = "num"
|
|
||||||
dir = 1
|
|
||||||
|
|
||||||
else if(istext(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
|
|
||||||
default = "text"
|
|
||||||
|
|
||||||
else if(isloc(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>REFERENCE</b>.")
|
|
||||||
default = "reference"
|
|
||||||
|
|
||||||
else if(isicon(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>ICON</b>.")
|
|
||||||
var_value = "[bicon(var_value)]"
|
|
||||||
default = "icon"
|
|
||||||
|
|
||||||
else if(ismatrix(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
|
||||||
default = "matrix"
|
|
||||||
|
|
||||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
|
||||||
default = "type"
|
|
||||||
|
|
||||||
else if(istype(var_value,/list))
|
|
||||||
to_chat(usr, "Variable appears to be <b>LIST</b>.")
|
|
||||||
default = "list"
|
|
||||||
|
|
||||||
else if(istype(var_value,/client))
|
|
||||||
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
|
|
||||||
default = "cancel"
|
|
||||||
|
|
||||||
else
|
|
||||||
to_chat(usr, "Variable appears to be <b>FILE</b>.")
|
|
||||||
default = "file"
|
|
||||||
|
|
||||||
to_chat(usr, "Variable contains: [var_value]")
|
|
||||||
if(dir)
|
|
||||||
switch(var_value)
|
|
||||||
if(1)
|
|
||||||
dir = "NORTH"
|
|
||||||
if(2)
|
|
||||||
dir = "SOUTH"
|
|
||||||
if(4)
|
|
||||||
dir = "EAST"
|
|
||||||
if(8)
|
|
||||||
dir = "WEST"
|
|
||||||
if(5)
|
|
||||||
dir = "NORTHEAST"
|
|
||||||
if(6)
|
|
||||||
dir = "SOUTHEAST"
|
|
||||||
if(9)
|
|
||||||
dir = "NORTHWEST"
|
|
||||||
if(10)
|
|
||||||
dir = "SOUTHWEST"
|
|
||||||
else
|
|
||||||
dir = null
|
|
||||||
if(dir)
|
|
||||||
to_chat(usr, "If a direction, direction is: [dir]")
|
|
||||||
|
|
||||||
var/class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
|
||||||
"num","type","icon","file","matrix", "edit referenced object","restore to default")
|
|
||||||
|
|
||||||
if(!class)
|
|
||||||
return
|
|
||||||
|
|
||||||
var/original_name
|
|
||||||
|
|
||||||
if (!istype(O, /atom))
|
|
||||||
original_name = "\ref[O] ([O])"
|
|
||||||
else
|
|
||||||
original_name = O:name
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
|
|
||||||
if("restore to default")
|
|
||||||
O.vars[variable] = initial(O.vars[variable])
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
for(var/turf/A in world)
|
for(var/turf/A in world)
|
||||||
if ( istype(A , O.type) )
|
if(is_valid_atom(A))
|
||||||
A.vars[variable] = O.vars[variable]
|
if(reset_to_initial)
|
||||||
|
A.vars[var_name] = initial(A.vars[var_name])
|
||||||
else
|
else
|
||||||
if(istype(O, /mob))
|
A.vars[var_name] = new_value
|
||||||
for(var/mob/M in mob_list)
|
CHECK_TICK
|
||||||
if (M.type == O.type)
|
else if(ispath(base_path, /mob))
|
||||||
M.vars[variable] = O.vars[variable]
|
for(var/mob/A in mob_list)
|
||||||
|
if(is_valid_atom(A))
|
||||||
else if(istype(O, /obj))
|
if(reset_to_initial)
|
||||||
|
A.vars[var_name] = initial(A.vars[var_name])
|
||||||
|
else
|
||||||
|
A.vars[var_name] = new_value
|
||||||
|
CHECK_TICK
|
||||||
|
else if(ispath(base_path, /area))
|
||||||
|
for(var/area/A in world)
|
||||||
|
if(is_valid_atom(A))
|
||||||
|
if(reset_to_initial)
|
||||||
|
A.vars[var_name] = initial(A.vars[var_name])
|
||||||
|
else
|
||||||
|
A.vars[var_name] = new_value
|
||||||
|
CHECK_TICK
|
||||||
|
else if(ispath(base_path, /obj))
|
||||||
for(var/obj/A in world)
|
for(var/obj/A in world)
|
||||||
if (A.type == O.type)
|
if(is_valid_atom(A))
|
||||||
A.vars[variable] = O.vars[variable]
|
if(reset_to_initial)
|
||||||
|
A.vars[var_name] = initial(A.vars[var_name])
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if("edit referenced object")
|
|
||||||
return .(O.vars[variable])
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
var/new_value = input("Enter new text:","Text",O.vars[variable]) as text|null
|
|
||||||
if(new_value == null)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(variable == "light_color")
|
|
||||||
O.set_light(l_color = new_value)
|
|
||||||
else
|
else
|
||||||
O.vars[variable] = new_value
|
A.vars[var_name] = new_value
|
||||||
|
CHECK_TICK
|
||||||
if(method)
|
else if(ispath(base_path, /atom))
|
||||||
if(istype(O, /mob))
|
for(var/atom/A in world)
|
||||||
for(var/mob/M in mob_list)
|
if(is_valid_atom(A))
|
||||||
if ( istype(M , O.type) )
|
if(reset_to_initial)
|
||||||
if(variable == "light_color")
|
A.vars[var_name] = initial(A.vars[var_name])
|
||||||
M.set_light(l_color = new_value)
|
|
||||||
else
|
else
|
||||||
M.vars[variable] = O.vars[variable]
|
A.vars[var_name] = new_value
|
||||||
|
CHECK_TICK
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
#undef is_valid_atom
|
||||||
for(var/obj/A in world)
|
#undef perform
|
||||||
if ( istype(A , O.type) )
|
|
||||||
if(variable == "light_color")
|
|
||||||
A.set_light(l_color = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
if(variable == "light_color")
|
|
||||||
A.set_light(l_color = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
if(variable == "light_color")
|
|
||||||
M.set_light(l_color = new_value)
|
|
||||||
else
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
if(variable == "light_color")
|
|
||||||
A.set_light(l_color = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
if(variable == "light_color")
|
|
||||||
A.set_light(l_color = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
var/new_value = input("Enter new number:","Num",\
|
|
||||||
O.vars[variable]) as num|null
|
|
||||||
if(new_value == null)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(variable=="light_range")
|
|
||||||
O.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
O.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
O.vars[variable] = new_value
|
|
||||||
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
if(variable=="light_range")
|
|
||||||
M.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
M.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
if(variable=="light_range")
|
|
||||||
A.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
A.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
if(variable=="light_range")
|
|
||||||
A.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
A.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
if(variable=="light_range")
|
|
||||||
M.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
M.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
if(variable=="light_range")
|
|
||||||
A.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
A.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
if(variable=="light_range")
|
|
||||||
A.set_light(new_value)
|
|
||||||
else if(variable == "light_power")
|
|
||||||
A.set_light(l_power = new_value)
|
|
||||||
else
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
var/new_value
|
|
||||||
new_value = input("Enter type:","Type",O.vars[variable]) as null|anything in typesof(/obj,/mob,/area,/turf)
|
|
||||||
if(new_value == null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = new_value
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
var/new_value = input("Pick file:","File",O.vars[variable]) as null|file
|
|
||||||
if(new_value == null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = new_value
|
|
||||||
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O.type, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O.type, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O.type, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O.type, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
var/new_value = input("Pick icon:","Icon",O.vars[variable]) as null|icon
|
|
||||||
if(new_value == null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = new_value
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000))
|
|
||||||
sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
if ("matrix")
|
|
||||||
var/matrix/new_value = modify_matrix_menu(O.vars[variable], verbose = FALSE)
|
|
||||||
if (!new_value)
|
|
||||||
return
|
|
||||||
|
|
||||||
O.vars[variable] = new_value
|
|
||||||
if(method)
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if ( istype(M , O.type) )
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000)) sleep(world.tick_lag)
|
|
||||||
if ( istype(A , O.type) )
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
else
|
|
||||||
if(istype(O, /mob))
|
|
||||||
for(var/mob/M in mob_list)
|
|
||||||
if (M.type == O.type)
|
|
||||||
M.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /obj))
|
|
||||||
for(var/obj/A in world)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
else if(istype(O, /turf))
|
|
||||||
var/count = 0
|
|
||||||
for(var/turf/A in world)
|
|
||||||
count++
|
|
||||||
if(!(count % 50000)) sleep(world.tick_lag)
|
|
||||||
if (A.type == O.type)
|
|
||||||
A.vars[variable] = O.vars[variable]
|
|
||||||
|
|
||||||
log_admin("[key_name(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]")
|
|
||||||
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]", 1)
|
|
||||||
|
|||||||
@@ -14,6 +14,182 @@ var/list/forbidden_varedit_object_types = list(
|
|||||||
feedback_add_details("admin_verb","EDITV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
feedback_add_details("admin_verb","EDITV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/proc/variable_set(mob/user, datum/edited_datum, edited_variable, autoselect_var_type = FALSE)
|
||||||
|
var/client/C
|
||||||
|
|
||||||
|
if(ismob(user))
|
||||||
|
C = user.client
|
||||||
|
else if(isclient(user))
|
||||||
|
C = user
|
||||||
|
|
||||||
|
if(!C || !C.holder)
|
||||||
|
return
|
||||||
|
|
||||||
|
#define V_MARKED_DATUM "marked_datum"
|
||||||
|
#define V_RESET "reset"
|
||||||
|
#define V_TEXT "text"
|
||||||
|
#define V_NUM "num"
|
||||||
|
#define V_TYPE "type"
|
||||||
|
#define V_LIST "list"
|
||||||
|
#define V_OBJECT "object"
|
||||||
|
#define V_ICON "icon"
|
||||||
|
#define V_FILE "file"
|
||||||
|
#define V_CLIENT "client"
|
||||||
|
#define V_NULL "null"
|
||||||
|
#define V_CANCEL "cancel"
|
||||||
|
#define V_MATRIX "matrix"
|
||||||
|
|
||||||
|
var/list/choices = list(\
|
||||||
|
"text" = V_TEXT,
|
||||||
|
"num" = V_NUM,
|
||||||
|
"type" = V_TYPE,
|
||||||
|
"empty list" = V_LIST,
|
||||||
|
"object (nearby)" = V_OBJECT,
|
||||||
|
"icon" = V_ICON,
|
||||||
|
"file" = V_FILE,
|
||||||
|
"client" = V_CLIENT,
|
||||||
|
"matrix" = V_MATRIX,
|
||||||
|
"null" = V_NULL,
|
||||||
|
)
|
||||||
|
|
||||||
|
if(C.holder.marked_datum)
|
||||||
|
var/list_item_name
|
||||||
|
if(isdatum(C.holder.marked_datum))
|
||||||
|
list_item_name = "marked datum ([C.holder.marked_datum.type])"
|
||||||
|
|
||||||
|
else if(isfile(C.holder.marked_datum))
|
||||||
|
list_item_name = "marked datum (file)"
|
||||||
|
|
||||||
|
else if(isicon(C.holder.marked_datum))
|
||||||
|
list_item_name = "marked datum (icon)"
|
||||||
|
|
||||||
|
else
|
||||||
|
list_item_name = "marked datum ([C.holder.marked_datum])"
|
||||||
|
|
||||||
|
choices[list_item_name] = V_MARKED_DATUM
|
||||||
|
|
||||||
|
if(istype(edited_datum) && edited_variable)
|
||||||
|
choices["restore to default"] = V_RESET
|
||||||
|
|
||||||
|
//Cancel belongs at the end
|
||||||
|
choices["CANCEL"] = V_CANCEL
|
||||||
|
|
||||||
|
|
||||||
|
var/class
|
||||||
|
var/var_value = null //Old value of the variable
|
||||||
|
var/result //New value of the variable
|
||||||
|
|
||||||
|
if(autoselect_var_type && istype(edited_datum) && edited_variable)
|
||||||
|
var_value = edited_datum.vars[edited_variable]
|
||||||
|
|
||||||
|
if(isnull(var_value))
|
||||||
|
to_chat(usr, "Unable to determine variable type.")
|
||||||
|
else if(isnum(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>NUM</b>.")
|
||||||
|
class = V_NUM
|
||||||
|
else if(istext(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
|
||||||
|
class = V_TEXT
|
||||||
|
else if(isloc(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>REFERENCE</b>. Selecting from nearby objects...")
|
||||||
|
class = V_OBJECT
|
||||||
|
else if(isicon(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>ICON</b>.")
|
||||||
|
class = V_ICON
|
||||||
|
else if(ispath(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
||||||
|
class = V_TYPE
|
||||||
|
else if(istype(var_value,/client))
|
||||||
|
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
|
||||||
|
class = V_CLIENT
|
||||||
|
else if(isfile(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>FILE</b>.")
|
||||||
|
class = V_FILE
|
||||||
|
else if(islist(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>LIST</b>.")
|
||||||
|
result = C.mod_list(var_value)
|
||||||
|
else if(ismatrix(var_value))
|
||||||
|
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
||||||
|
result = C.modify_matrix_menu(var_value)
|
||||||
|
|
||||||
|
|
||||||
|
if(!class && !result)
|
||||||
|
class = input("What kind of variable?","Variable Type") in choices
|
||||||
|
var/selected_type = choices[class]
|
||||||
|
|
||||||
|
if(!result)
|
||||||
|
switch(selected_type)
|
||||||
|
if(V_CANCEL)
|
||||||
|
return
|
||||||
|
|
||||||
|
if(V_TEXT)
|
||||||
|
result = input("Enter new text:","Text",null) as text
|
||||||
|
|
||||||
|
if(V_NUM)
|
||||||
|
result = input("Enter new number:","Num",0) as num
|
||||||
|
|
||||||
|
if(V_TYPE)
|
||||||
|
var/partial_type = input("Enter type, or leave blank to see all types", "Type") as text|null
|
||||||
|
|
||||||
|
var/list/matches = matching_type_list(partial_type, /datum)
|
||||||
|
result = input("Select type","Type") as null|anything in matches
|
||||||
|
|
||||||
|
if(V_LIST)
|
||||||
|
result = list()
|
||||||
|
|
||||||
|
if(V_OBJECT)
|
||||||
|
result = input("Select reference:","Reference",src) as mob|obj|turf|area in range(8, get_turf(user))
|
||||||
|
|
||||||
|
if(V_FILE)
|
||||||
|
result = input("Pick file:","File") as file
|
||||||
|
|
||||||
|
if(V_ICON)
|
||||||
|
result = input("Pick icon:","Icon") as icon
|
||||||
|
|
||||||
|
if(V_CLIENT)
|
||||||
|
var/list/keys = list()
|
||||||
|
for(var/mob/M in mob_list)
|
||||||
|
if(M.client)
|
||||||
|
keys += M.client
|
||||||
|
|
||||||
|
result = input("Please, select a player!", "Selection", null, null) as null|anything in keys
|
||||||
|
|
||||||
|
if(V_MARKED_DATUM)
|
||||||
|
result = C.holder.marked_datum
|
||||||
|
|
||||||
|
if(V_RESET)
|
||||||
|
if(istype(edited_datum) && edited_variable)
|
||||||
|
result = initial(edited_datum.vars[edited_variable])
|
||||||
|
|
||||||
|
edited_datum.vars[edited_variable] = result
|
||||||
|
to_chat(user, "Restored '[edited_variable]' to original value - [result]")
|
||||||
|
|
||||||
|
if(V_NULL)
|
||||||
|
result = null
|
||||||
|
|
||||||
|
if(V_MATRIX)
|
||||||
|
result = matrix()
|
||||||
|
|
||||||
|
else
|
||||||
|
to_chat(user, "Unknown type: [selected_type]")
|
||||||
|
|
||||||
|
if(istype(edited_datum))
|
||||||
|
edited_datum.variable_edited(edited_variable, var_value, result)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
#undef V_MARKED_DATUM
|
||||||
|
#undef V_RESET
|
||||||
|
#undef V_TEXT
|
||||||
|
#undef V_NUM
|
||||||
|
#undef V_TYPE
|
||||||
|
#undef V_LIST
|
||||||
|
#undef V_OBJECT
|
||||||
|
#undef V_ICON
|
||||||
|
#undef V_FILE
|
||||||
|
#undef V_CLIENT
|
||||||
|
#undef V_NULL
|
||||||
|
|
||||||
/client/proc/cmd_modify_ticker_variables()
|
/client/proc/cmd_modify_ticker_variables()
|
||||||
set category = "Debug"
|
set category = "Debug"
|
||||||
set name = "Edit Ticker Variables"
|
set name = "Edit Ticker Variables"
|
||||||
@@ -24,576 +200,38 @@ var/list/forbidden_varedit_object_types = list(
|
|||||||
src.modify_variables(ticker)
|
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!
|
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
|
//Select and add a value to list L
|
||||||
|
|
||||||
|
|
||||||
var/class = "text"
|
|
||||||
if(src.holder && src.holder.marked_datum)
|
|
||||||
class = input("What kind of variable?","Variable Type") as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])")
|
|
||||||
else
|
|
||||||
class = input("What kind of variable?","Variable Type") as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default")
|
|
||||||
|
|
||||||
if(!class)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
|
||||||
class = "marked datum"
|
|
||||||
|
|
||||||
var/var_value = null
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
var_value = input("Enter new text:","Text") as null|message
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
var_value = input("Enter new number:","Num") as null|num
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
var_value = input("Enter type:","Type") as null|anything in typesof(/obj,/mob,/area,/turf)
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
var_value = input("Select reference:","Reference") as null|mob|obj|turf|area in world
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
var_value = input("Select reference:","Reference") as null|mob in world
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
var_value = input("Pick file:","File") as null|file
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
var_value = input("Pick icon:","Icon") as null|icon
|
|
||||||
|
|
||||||
if("marked datum")
|
|
||||||
var_value = holder.marked_datum
|
|
||||||
|
|
||||||
if(!var_value)
|
|
||||||
return
|
|
||||||
|
|
||||||
return var_value
|
|
||||||
|
|
||||||
|
|
||||||
/client/proc/mod_list_add(var/list/L)
|
/client/proc/mod_list_add(var/list/L)
|
||||||
|
if(!check_rights(R_VAREDIT))
|
||||||
|
|
||||||
var/class = "text"
|
|
||||||
if(src.holder && src.holder.marked_datum)
|
|
||||||
class = input("What kind of variable?","Variable Type") as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])")
|
|
||||||
else
|
|
||||||
class = input("What kind of variable?","Variable Type") as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default")
|
|
||||||
|
|
||||||
if(!class)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
var/added_value = variable_set(src, L)
|
||||||
class = "marked datum"
|
|
||||||
|
|
||||||
var/var_value = null
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
var_value = input("Enter new text:","Text") as message
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
var_value = input("Enter new number:","Num") as num
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
var_value = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
var_value = input("Select reference:","Reference") as mob|obj|turf|area in world
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
var_value = input("Select reference:","Reference") as mob in world
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
var_value = input("Pick file:","File") as file
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
var_value = input("Pick icon:","Icon") as icon
|
|
||||||
|
|
||||||
if("marked datum")
|
|
||||||
var_value = holder.marked_datum
|
|
||||||
|
|
||||||
if(!var_value)
|
|
||||||
return
|
|
||||||
|
|
||||||
switch(alert("Would you like to associate a var with the list entry?",,"Yes","No"))
|
switch(alert("Would you like to associate a var with the list entry?",,"Yes","No"))
|
||||||
if("Yes")
|
if("Yes")
|
||||||
L += var_value
|
L[added_value] = variable_set(src, L) //haha
|
||||||
L[var_value] = mod_list_add_ass() //haha
|
else
|
||||||
if("No")
|
L.Add(added_value)
|
||||||
L += var_value
|
|
||||||
|
|
||||||
|
//Modify a list - either add or remove a balue
|
||||||
/client/proc/mod_list(var/list/L)
|
/client/proc/mod_list(var/list/L)
|
||||||
if(!check_rights(R_VAREDIT))
|
if(!check_rights(R_VAREDIT))
|
||||||
return
|
return
|
||||||
|
|
||||||
if(!istype(L,/list))
|
//var/list/names = sortList(L)
|
||||||
if(alert("Make a new list?", "Not a List.", "Yes", "No") == "No")
|
//Don't sort the list - item order is important in some lists
|
||||||
|
|
||||||
|
var/variable = input("Select a variable to remove from the list, or select (ADD VAR) to add a new one","Var") as null|anything in L + "(ADD VAR)"
|
||||||
|
|
||||||
|
if(!variable)
|
||||||
return
|
return
|
||||||
else
|
else if(variable == "(ADD VAR)")
|
||||||
L = list()
|
|
||||||
|
|
||||||
var/list/names = sortList(L)
|
|
||||||
|
|
||||||
var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
|
|
||||||
|
|
||||||
if(variable == "(ADD VAR)")
|
|
||||||
mod_list_add(L)
|
mod_list_add(L)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(!variable)
|
|
||||||
return
|
|
||||||
|
|
||||||
var/default
|
|
||||||
|
|
||||||
var/dir
|
|
||||||
|
|
||||||
if(!can_edit_var(variable))
|
|
||||||
return
|
|
||||||
|
|
||||||
if(isnull(variable))
|
|
||||||
to_chat(usr, "Unable to determine variable type.")
|
|
||||||
|
|
||||||
else if(isnum(variable))
|
|
||||||
to_chat(usr, "Variable appears to be <b>NUM</b>.")
|
|
||||||
default = "num"
|
|
||||||
dir = 1
|
|
||||||
|
|
||||||
else if(istext(variable))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
|
|
||||||
default = "text"
|
|
||||||
|
|
||||||
else if(isloc(variable))
|
|
||||||
to_chat(usr, "Variable appears to be <b>REFERENCE</b>.")
|
|
||||||
default = "reference"
|
|
||||||
|
|
||||||
else if(isicon(variable))
|
|
||||||
to_chat(usr, "Variable appears to be <b>ICON</b>.")
|
|
||||||
variable = "[bicon(variable)]"
|
|
||||||
default = "icon"
|
|
||||||
|
|
||||||
else if(istype(variable,/atom) || istype(variable,/datum))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
|
||||||
default = "type"
|
|
||||||
|
|
||||||
else if(istype(variable,/list))
|
|
||||||
to_chat(usr, "Variable appears to be <b>LIST</b>.")
|
|
||||||
default = "list"
|
|
||||||
|
|
||||||
else if(istype(variable,/client))
|
|
||||||
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
|
|
||||||
default = "cancel"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
to_chat(usr, "Variable appears to be <b>FILE</b>.")
|
L.Remove(variable)
|
||||||
default = "file"
|
|
||||||
|
|
||||||
to_chat(usr, "Variable contains: [variable]")
|
return L
|
||||||
if(dir)
|
|
||||||
switch(variable)
|
|
||||||
if(1)
|
|
||||||
dir = "NORTH"
|
|
||||||
if(2)
|
|
||||||
dir = "SOUTH"
|
|
||||||
if(4)
|
|
||||||
dir = "EAST"
|
|
||||||
if(8)
|
|
||||||
dir = "WEST"
|
|
||||||
if(5)
|
|
||||||
dir = "NORTHEAST"
|
|
||||||
if(6)
|
|
||||||
dir = "SOUTHEAST"
|
|
||||||
if(9)
|
|
||||||
dir = "NORTHWEST"
|
|
||||||
if(10)
|
|
||||||
dir = "SOUTHWEST"
|
|
||||||
else
|
|
||||||
dir = null
|
|
||||||
|
|
||||||
if(dir)
|
|
||||||
to_chat(usr, "If a direction, direction is: [dir]")
|
|
||||||
|
|
||||||
var/class = "text"
|
|
||||||
if(src.holder && src.holder.marked_datum)
|
|
||||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])", "DELETE FROM LIST")
|
|
||||||
else
|
|
||||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default", "DELETE FROM LIST")
|
|
||||||
|
|
||||||
if(!class)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
|
||||||
class = "marked datum"
|
|
||||||
|
|
||||||
switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet.
|
|
||||||
|
|
||||||
if("list")
|
|
||||||
mod_list(variable)
|
|
||||||
|
|
||||||
if("restore to default")
|
|
||||||
L[L.Find(variable)]=initial(variable)
|
|
||||||
|
|
||||||
if("edit referenced object")
|
|
||||||
modify_variables(variable)
|
|
||||||
|
|
||||||
if("DELETE FROM LIST")
|
|
||||||
L -= variable
|
|
||||||
return
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newText = input("Enter new text:","Text") as null|message
|
|
||||||
if(!newText)
|
|
||||||
return
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newText
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newText
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newNum = input("Enter new number:","Num") as null|num
|
|
||||||
if(!newNum)
|
|
||||||
return
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newNum
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newNum
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newType = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newType
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newType
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newRef = input("Select reference:","Reference") as null|mob|obj|turf|area in world
|
|
||||||
if(!newRef)
|
|
||||||
return
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newRef
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newRef
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newMob = input("Select reference:","Reference") as null|mob in world
|
|
||||||
if(!newMob)
|
|
||||||
return
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newMob
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newMob
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newFile = input("Pick file:","File") as file
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newFile
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newFile
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newIcon = input("Pick icon:","Icon") as icon
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newIcon
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newIcon
|
|
||||||
|
|
||||||
if("marked datum")
|
|
||||||
var/thing = L["[variable]"]
|
|
||||||
var/newThing = holder.marked_datum
|
|
||||||
if(!isnull(thing))
|
|
||||||
L["[variable]"] = newThing
|
|
||||||
else
|
|
||||||
L[L.Find(variable)] = newThing
|
|
||||||
|
|
||||||
|
|
||||||
/client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0)
|
|
||||||
if(!check_rights(R_VAREDIT))
|
|
||||||
return
|
|
||||||
|
|
||||||
if(holder && !(holder.rights & (R_PERMISSIONS)))
|
|
||||||
for(var/p in forbidden_varedit_object_types)
|
|
||||||
if( istype(O,p) )
|
|
||||||
to_chat(usr, "<span class='warning'>It is forbidden to edit this object's variables.</span>")
|
|
||||||
return
|
|
||||||
|
|
||||||
var/class
|
|
||||||
var/variable
|
|
||||||
var/var_value
|
|
||||||
|
|
||||||
if(param_var_name)
|
|
||||||
if(!param_var_name in O.vars)
|
|
||||||
to_chat(src, "A variable with this name ([param_var_name]) doesn't exist in this atom ([O])")
|
|
||||||
return
|
|
||||||
|
|
||||||
variable = param_var_name
|
|
||||||
|
|
||||||
if(!can_edit_var(variable))
|
|
||||||
return
|
|
||||||
|
|
||||||
var_value = O.vars[variable]
|
|
||||||
|
|
||||||
if(autodetect_class)
|
|
||||||
if(isnull(var_value))
|
|
||||||
to_chat(usr, "Unable to determine variable type.")
|
|
||||||
class = null
|
|
||||||
autodetect_class = null
|
|
||||||
else if(isnum(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>NUM</b>.")
|
|
||||||
class = "num"
|
|
||||||
dir = 1
|
|
||||||
|
|
||||||
else if(istext(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
|
|
||||||
class = "text"
|
|
||||||
|
|
||||||
else if(isloc(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>REFERENCE</b>.")
|
|
||||||
class = "reference"
|
|
||||||
|
|
||||||
else if(isicon(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>ICON</b>.")
|
|
||||||
var_value = "[bicon(var_value)]"
|
|
||||||
class = "icon"
|
|
||||||
|
|
||||||
else if(ismatrix(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
|
||||||
class = "matrix"
|
|
||||||
|
|
||||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
|
||||||
class = "type"
|
|
||||||
|
|
||||||
else if(istype(var_value,/list))
|
|
||||||
to_chat(usr, "Variable appears to be <b>LIST</b>.")
|
|
||||||
class = "list"
|
|
||||||
|
|
||||||
else if(istype(var_value,/client))
|
|
||||||
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
|
|
||||||
class = "cancel"
|
|
||||||
|
|
||||||
else
|
|
||||||
to_chat(usr, "Variable appears to be <b>FILE</b>.")
|
|
||||||
class = "file"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
var/list/names = list()
|
|
||||||
for (var/V in O.vars)
|
|
||||||
names += V
|
|
||||||
|
|
||||||
names = sortList(names)
|
|
||||||
|
|
||||||
variable = input("Which var?","Var") as null|anything in names
|
|
||||||
if(!variable)
|
|
||||||
return
|
|
||||||
var_value = O.vars[variable]
|
|
||||||
|
|
||||||
if(!can_edit_var(variable))
|
|
||||||
return
|
|
||||||
|
|
||||||
if(!autodetect_class)
|
|
||||||
|
|
||||||
var/dir
|
|
||||||
var/default
|
|
||||||
if(isnull(var_value))
|
|
||||||
to_chat(usr, "Unable to determine variable type.")
|
|
||||||
|
|
||||||
else if(isnum(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>NUM</b>.")
|
|
||||||
default = "num"
|
|
||||||
dir = 1
|
|
||||||
|
|
||||||
else if(istext(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
|
|
||||||
default = "text"
|
|
||||||
|
|
||||||
else if(isloc(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>REFERENCE</b>.")
|
|
||||||
default = "reference"
|
|
||||||
|
|
||||||
else if(isicon(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>ICON</b>.")
|
|
||||||
var_value = "[bicon(var_value)]"
|
|
||||||
default = "icon"
|
|
||||||
|
|
||||||
else if(ismatrix(var_value))
|
|
||||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
|
||||||
default = "matrix"
|
|
||||||
|
|
||||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
|
||||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
|
||||||
default = "type"
|
|
||||||
|
|
||||||
else if(istype(var_value,/list))
|
|
||||||
to_chat(usr, "Variable appears to be <b>LIST</b>.")
|
|
||||||
default = "list"
|
|
||||||
|
|
||||||
else if(istype(var_value,/client))
|
|
||||||
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
|
|
||||||
default = "cancel"
|
|
||||||
|
|
||||||
else
|
|
||||||
to_chat(usr, "Variable appears to be <b>FILE</b>.")
|
|
||||||
default = "file"
|
|
||||||
|
|
||||||
to_chat(usr, "Variable contains: [var_value]")
|
|
||||||
if(dir)
|
|
||||||
switch(var_value)
|
|
||||||
if(1)
|
|
||||||
dir = "NORTH"
|
|
||||||
if(2)
|
|
||||||
dir = "SOUTH"
|
|
||||||
if(4)
|
|
||||||
dir = "EAST"
|
|
||||||
if(8)
|
|
||||||
dir = "WEST"
|
|
||||||
if(5)
|
|
||||||
dir = "NORTHEAST"
|
|
||||||
if(6)
|
|
||||||
dir = "SOUTHEAST"
|
|
||||||
if(9)
|
|
||||||
dir = "NORTHWEST"
|
|
||||||
if(10)
|
|
||||||
dir = "SOUTHWEST"
|
|
||||||
else
|
|
||||||
dir = null
|
|
||||||
if(dir)
|
|
||||||
to_chat(usr, "If a direction, direction is: [dir]")
|
|
||||||
|
|
||||||
if(src.holder && src.holder.marked_datum)
|
|
||||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","matrix","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])")
|
|
||||||
else
|
|
||||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
|
||||||
"num","type","reference","mob reference", "icon","file","list","matrix","edit referenced object","restore to default")
|
|
||||||
|
|
||||||
if(!class)
|
|
||||||
return
|
|
||||||
|
|
||||||
var/original_name
|
|
||||||
|
|
||||||
if (!istype(O, /atom))
|
|
||||||
original_name = "\ref[O] ([O])"
|
|
||||||
else
|
|
||||||
original_name = O:name
|
|
||||||
|
|
||||||
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
|
|
||||||
class = "marked datum"
|
|
||||||
|
|
||||||
switch(class)
|
|
||||||
|
|
||||||
if("list")
|
|
||||||
mod_list(O.vars[variable])
|
|
||||||
return
|
|
||||||
|
|
||||||
if("restore to default")
|
|
||||||
O.vars[variable] = initial(O.vars[variable])
|
|
||||||
|
|
||||||
if("edit referenced object")
|
|
||||||
return .(O.vars[variable])
|
|
||||||
|
|
||||||
if("text")
|
|
||||||
if(variable == "light_color")
|
|
||||||
var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|message
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.set_light(l_color = var_new)
|
|
||||||
else
|
|
||||||
var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|message
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("num")
|
|
||||||
if(variable=="light_range")
|
|
||||||
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
|
|
||||||
if(var_new == null)
|
|
||||||
return
|
|
||||||
O.set_light(var_new)
|
|
||||||
|
|
||||||
else if(variable=="light_power")
|
|
||||||
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
|
|
||||||
if(var_new == null)
|
|
||||||
return
|
|
||||||
O.set_light(l_power = var_new)
|
|
||||||
|
|
||||||
else if(variable=="stat")
|
|
||||||
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
|
|
||||||
if(var_new == null)
|
|
||||||
return
|
|
||||||
if((O.vars[variable] == 2) && (var_new < 2))//Bringing the dead back to life
|
|
||||||
if(ismob(O))
|
|
||||||
var/mob/M = O
|
|
||||||
M.resurrect()
|
|
||||||
if((O.vars[variable] < 2) && (var_new == 2))//Kill he
|
|
||||||
living_mob_list -= O
|
|
||||||
dead_mob_list += O
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
else
|
|
||||||
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("type")
|
|
||||||
var/var_new = input("Enter type:","Type",O.vars[variable]) as null|anything in typesof(/obj,/mob,/area,/turf)
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("reference")
|
|
||||||
var/var_new = input("Select reference:","Reference",O.vars[variable]) as null|mob|obj|turf|area in world
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("mob reference")
|
|
||||||
var/var_new = input("Select reference:","Reference",O.vars[variable]) as null|mob in world
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("file")
|
|
||||||
var/var_new = input("Pick file:","File",O.vars[variable]) as null|file
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("icon")
|
|
||||||
var/var_new = input("Pick icon:","Icon",O.vars[variable]) as null|icon
|
|
||||||
if(var_new==null)
|
|
||||||
return
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
if("marked datum")
|
|
||||||
O.vars[variable] = holder.marked_datum
|
|
||||||
|
|
||||||
if("matrix")
|
|
||||||
var/matrix/var_new = modify_matrix_menu(O.vars[variable])
|
|
||||||
if (!var_new)
|
|
||||||
return
|
|
||||||
|
|
||||||
O.vars[variable] = var_new
|
|
||||||
|
|
||||||
world.log << "### VarEdit by [src]: [O.type] [variable]=[html_encode("[O.vars[variable]]")]"
|
|
||||||
log_admin("[key_name(src)] modified [original_name]'s [variable] to [O.vars[variable]]")
|
|
||||||
message_admins("[key_name_admin(src)] modified [original_name]'s [variable] to [O.vars[variable]]", 1)
|
|
||||||
|
|
||||||
/client/proc/modify_matrix_menu(var/matrix/M = matrix(), var/verbose = TRUE)
|
/client/proc/modify_matrix_menu(var/matrix/M = matrix(), var/verbose = TRUE)
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
|||||||
@@ -4,6 +4,17 @@
|
|||||||
/mob
|
/mob
|
||||||
plane = MOB_PLANE
|
plane = MOB_PLANE
|
||||||
|
|
||||||
|
/mob/variable_edited(var_name, old_value, new_value)
|
||||||
|
.=..()
|
||||||
|
|
||||||
|
switch(var_name)
|
||||||
|
if("stat")
|
||||||
|
if((old_value == 2) && (new_value < 2))//Bringing the dead back to life
|
||||||
|
resurrect()
|
||||||
|
else if((old_value < 2) && (new_value == 2))//Kill he
|
||||||
|
living_mob_list.Remove(src)
|
||||||
|
dead_mob_list.Add(src)
|
||||||
|
|
||||||
/mob/recycle(var/datum/materials)
|
/mob/recycle(var/datum/materials)
|
||||||
return RECYK_BIOLOGICAL
|
return RECYK_BIOLOGICAL
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user