From 8a7a17b8e63e46a01c11c38cbe457208d6ae55f8 Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Fri, 19 Feb 2016 01:20:01 -0800 Subject: [PATCH] Adds matrix and path editing to the variable viewer --- code/__HELPERS/type2type.dm | 21 +- code/datums/datumvars.dm | 819 ++++++++++---------- code/game/machinery/constructable_frame.dm | 24 +- code/modules/admin/verbs/modifyvariables.dm | 289 +++---- 4 files changed, 557 insertions(+), 596 deletions(-) diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 2421c64b62f..99c641f6dd0 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -424,4 +424,23 @@ proc/tg_text2list(text, glue=",", assocglue=";") if(temp <= 16) . = 0 else - . = max(0, min(255, 138.5177312231 * log(temp - 10) - 305.0447927307)) \ No newline at end of file + . = max(0, min(255, 138.5177312231 * log(temp - 10) - 305.0447927307)) + +//Argument: Give this a space-separated string consisting of 6 numbers. Returns null if you don't +/proc/text2matrix(var/matrixtext) + var/list/matrixtext_list = text2list(matrixtext, " ") + var/list/matrix_list = list() + for(var/item in matrixtext_list) + var/entry = text2num(item) + if(entry == null) + return null + matrix_list += entry + if(matrix_list.len < 6) + return null + var/a = matrix_list[1] + var/b = matrix_list[2] + var/c = matrix_list[3] + var/d = matrix_list[4] + var/e = matrix_list[5] + var/f = matrix_list[6] + return matrix(a, b, c, d, e, f) \ No newline at end of file diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 89f4a277796..29ebdfe8b4d 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -1,434 +1,433 @@ // reference: /client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0) -client - proc/debug_variables(datum/D in world) - set category = "Debug" - set name = "View Variables" - //set src in world +/client/proc/debug_variables(datum/D in world) + set category = "Debug" + set name = "View Variables" + //set src in world - if(!usr.client || !usr.client.holder) - usr << "\red You need to be an administrator to access this." - return - - - var/title = "" - var/body = "" - - if(!D) return - if(istype(D, /atom)) - var/atom/A = D - title = "[A.name] (\ref[A]) = [A.type]" - - #ifdef VARSICON - if (A.icon) - body += debug_variable("icon", new/icon(A.icon, A.icon_state, A.dir), 0) - #endif - - var/icon/sprite - - if(istype(D,/atom)) - var/atom/AT = D - if(AT.icon && AT.icon_state) - sprite = new /icon(AT.icon, AT.icon_state) - usr << browse_rsc(sprite, "view_vars_sprite.png") - - title = "[D] (\ref[D]) = [D.type]" - - body += {" "} - - body += "" - - body += "
" - - if(sprite) - body += "" - - body += "
" - else - body += "
" - - body += "
" - - if(istype(D,/atom)) - var/atom/A = D - if(isliving(A)) - body += "[D]" - if(A.dir) - body += "
<< [dir2text(A.dir)] >>" - var/mob/living/M = A - body += "
[M.ckey ? M.ckey : "No ckey"] / [M.real_name ? M.real_name : "No real name"]" - body += {" -
- BRUTE:[M.getBruteLoss()] - FIRE:[M.getFireLoss()] - TOXIN:[M.getToxLoss()] - OXY:[M.getOxyLoss()] - CLONE:[M.getCloneLoss()] - BRAIN:[M.getBrainLoss()] - - - - "} - else - body += "[D]" - if(A.dir) - body += "
<< [dir2text(A.dir)] >>" - else - body += "[D]" - - body += "
" - - body += "
" - - var/formatted_type = text("[D.type]") - if(length(formatted_type) > 25) - var/middle_point = length(formatted_type) / 2 - var/splitpoint = findtext(formatted_type,"/",middle_point) - if(splitpoint) - formatted_type = "[copytext(formatted_type,1,splitpoint)]
[copytext(formatted_type,splitpoint)]" - else - formatted_type = "Type too long" //No suitable splitpoint (/) found. - - body += "
[formatted_type]" - - if(src.holder && src.holder.marked_datum && src.holder.marked_datum == D) - body += "
Marked Object" - - body += "
" - - body += "
Refresh" - - //if(ismob(D)) - // body += "
Show player panel

" - - body += {"
-
" - - body += "

" - - body += "E - Edit, tries to determine the variable type by itself.
" - body += "C - Change, asks you for the var type first.
" - body += "M - Mass modify: changes this variable for all objects of this type.

" - - body += "
Search:

" - - body += "
    " - - var/list/names = list() - for (var/V in D.vars) - names += V - - names = sortList(names) - - for (var/V in names) - body += debug_variable(V, D.vars[V], 0, D) - - body += "
" - - var/html = "" - if (title) - html += "[title]" - html += {""} - html += "" - html += body - - html += {" - - "} - - html += "" - - usr << browse(html, "window=variables\ref[D];size=475x650") - + if(!usr.client || !usr.client.holder) + usr << "\red You need to be an administrator to access this." return - proc/debug_variable(name, value, level, var/datum/DA = null) - var/html = "" - if(DA) - html += "
  • (E) (C) (M) " + var/title = "" + var/body = "" + + if(!D) return + if(istype(D, /atom)) + var/atom/A = D + title = "[A.name] (\ref[A]) = [A.type]" + + #ifdef VARSICON + if (A.icon) + body += debug_variable("icon", new/icon(A.icon, A.icon_state, A.dir), 0) + #endif + + var/icon/sprite + + if(istype(D,/atom)) + var/atom/AT = D + if(AT.icon && AT.icon_state) + sprite = new /icon(AT.icon, AT.icon_state) + usr << browse_rsc(sprite, "view_vars_sprite.png") + + title = "[D] (\ref[D]) = [D.type]" + + body += {" "} + + body += "" + + body += "
    " + + if(sprite) + body += "" + + body += "
    " + else + body += "
    " + + body += "
    " + + if(istype(D,/atom)) + var/atom/A = D + if(isliving(A)) + body += "[D]" + if(A.dir) + body += "
    << [dir2text(A.dir)] >>" + var/mob/living/M = A + body += "
    [M.ckey ? M.ckey : "No ckey"] / [M.real_name ? M.real_name : "No real name"]" + body += {" +
    + BRUTE:[M.getBruteLoss()] + FIRE:[M.getFireLoss()] + TOXIN:[M.getToxLoss()] + OXY:[M.getOxyLoss()] + CLONE:[M.getCloneLoss()] + BRAIN:[M.getBrainLoss()] + + + + "} else - html += "
  • " + body += "[D]" + if(A.dir) + body += "
    << [dir2text(A.dir)] >>" + else + body += "[D]" - if (isnull(value)) - html += "[name] = null" + body += "
  • " - else if (istext(value)) - html += "[name] = \"[value]\"" + body += "
    " - else if (isicon(value)) - #ifdef VARSICON - var/icon/I = new/icon(value) - var/rnd = rand(1,10000) - var/rname = "tmp\ref[I][rnd].png" - usr << browse_rsc(I, rname) - html += "[name] = ([value]) " - #else - html += "[name] = /icon ([value])" - #endif + var/formatted_type = text("[D.type]") + if(length(formatted_type) > 25) + var/middle_point = length(formatted_type) / 2 + var/splitpoint = findtext(formatted_type,"/",middle_point) + if(splitpoint) + formatted_type = "[copytext(formatted_type,1,splitpoint)]
    [copytext(formatted_type,splitpoint)]" + else + formatted_type = "Type too long" //No suitable splitpoint (/) found. + + body += "
    [formatted_type]" + + if(src.holder && src.holder.marked_datum && src.holder.marked_datum == D) + body += "
    Marked Object" + + body += "
    " + + body += "
    Refresh" + + //if(ismob(D)) + // body += "
    Show player panel

    " + + body += {"
    +
    " + + body += "

    " + + body += "E - Edit, tries to determine the variable type by itself.
    " + body += "C - Change, asks you for the var type first.
    " + body += "M - Mass modify: changes this variable for all objects of this type.

    " + + body += "
    Search:

    " + + body += "
      " + + var/list/names = list() + for (var/V in D.vars) + names += V + + names = sortList(names) + + for (var/V in names) + body += debug_variable(V, D.vars[V], 0, D) + + body += "
    " + + var/html = "" + if (title) + html += "[title]" + html += {""} + html += "" + html += body + + html += {" + + "} + + html += "" + + usr << browse(html, "window=variables\ref[D];size=475x650") + + return + +/client/proc/debug_variable(name, value, level, var/datum/DA = null) + var/html = "" + + if(DA) + html += "
  • (E) (C) (M) " + else + html += "
  • " + + if (isnull(value)) + html += "[name] = null" + + else if (istext(value)) + html += "[name] = \"[value]\"" + + else if (isicon(value)) + #ifdef VARSICON + var/icon/I = new/icon(value) + var/rnd = rand(1,10000) + var/rname = "tmp\ref[I][rnd].png" + usr << browse_rsc(I, rname) + html += "[name] = ([value]) " + #else + html += "[name] = /icon ([value])" + #endif /* else if (istype(value, /image)) - #ifdef VARSICON - var/rnd = rand(1, 10000) - var/image/I = value + #ifdef VARSICON + var/rnd = rand(1, 10000) + var/image/I = value - src << browse_rsc(I.icon, "tmp\ref[value][rnd].png") - html += "[name] = " - #else - html += "[name] = /image ([value])" - #endif + src << browse_rsc(I.icon, "tmp\ref[value][rnd].png") + html += "[name] = " + #else + html += "[name] = /image ([value])" + #endif */ - else if (isfile(value)) - html += "[name] = '[value]'" + else if (isfile(value)) + html += "[name] = '[value]'" - else if (istype(value, /datum)) - var/datum/D = value - html += "[name] \ref[value] = [D.type]" + else if (istype(value, /datum)) + var/datum/D = value + html += "[name] \ref[value] = [D.type]" - else if (istype(value, /client)) - var/client/C = value - html += "[name] \ref[value] = [C] [C.type]" - // - else if (istype(value, /list)) - var/list/L = value - html += "[name] = /list ([L.len])" + else if (istype(value, /client)) + var/client/C = value + html += "[name] \ref[value] = [C] [C.type]" +// + else if (istype(value, /list)) + var/list/L = value + html += "[name] = /list ([L.len])" - if (L.len > 0 && !(name == "underlays" || name == "overlays" || name == "vars" || L.len > 500)) - // not sure if this is completely right... - if(0) //(L.vars.len > 0) - html += "
      " - html += "
    " - else - html += "" + if (L.len > 0 && !(name == "underlays" || name == "overlays" || name == "vars" || L.len > 500)) + // not sure if this is completely right... + if(0) //(L.vars.len > 0) + html += "
      " + html += "
    " + else + html += "" - else - html += "[name] = [value]" - /* - // Bitfield stuff - if(round(value)==value) // Require integers. - var/idx=0 - var/bit=0 - var/bv=0 - html += "
    " - for(var/block=0;block<8;block++) - html += " " - for(var/i=0;i<4;i++) - idx=(block*4)+i - bit=1 << idx - bv=value & bit - html += "[bv?1:0]" - html += "" - html += "
    " - */ - html += "
  • " + else + html += "[name] = [value]" + /* + // Bitfield stuff + if(round(value)==value) // Require integers. + var/idx=0 + var/bit=0 + var/bv=0 + html += "
    " + for(var/block=0;block<8;block++) + html += " " + for(var/i=0;i<4;i++) + idx=(block*4)+i + bit=1 << idx + bv=value & bit + html += "[bv?1:0]" + html += "" + html += "
    " + */ + html += "" - return html + return html /client/proc/view_var_Topic(href, href_list, hsrc) //This should all be moved over to datum/admins/Topic() or something ~Carn diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index c62c8131f25..b52a15d77c3 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -499,7 +499,7 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/destructive_analyzer name = "Circuit board (Destructive Analyzer)" - build_path = "/obj/machinery/r_n_d/destructive_analyzer" + build_path = /obj/machinery/r_n_d/destructive_analyzer board_type = "machine" origin_tech = "magnets=2;engineering=2;programming=2" frame_desc = "Requires 1 Scanning Module, 1 Manipulator, and 1 Micro-Laser." @@ -510,7 +510,7 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/autolathe name = "Circuit board (Autolathe)" - build_path = "/obj/machinery/autolathe" + build_path = /obj/machinery/autolathe board_type = "machine" origin_tech = "engineering=2;programming=2" frame_desc = "Requires 3 Matter Bins, 1 Manipulator, and 1 Console Screen." @@ -521,7 +521,7 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/protolathe name = "Circuit board (Protolathe)" - build_path = "/obj/machinery/r_n_d/protolathe" + build_path = /obj/machinery/r_n_d/protolathe board_type = "machine" origin_tech = "engineering=2;programming=2" frame_desc = "Requires 2 Matter Bins, 2 Manipulators, and 2 Beakers." @@ -533,7 +533,7 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/circuit_imprinter name = "Circuit board (Circuit Imprinter)" - build_path = "/obj/machinery/r_n_d/circuit_imprinter" + build_path = /obj/machinery/r_n_d/circuit_imprinter board_type = "machine" origin_tech = "engineering=2;programming=2" frame_desc = "Requires 1 Matter Bin, 1 Manipulator, and 2 Beakers." @@ -544,7 +544,7 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/pacman name = "Circuit Board (PACMAN-type Generator)" - build_path = "/obj/machinery/power/port_gen/pacman" + build_path = /obj/machinery/power/port_gen/pacman board_type = "machine" origin_tech = "programming=3:powerstorage=3;plasmatech=3;engineering=3" frame_desc = "Requires 1 Matter Bin, 1 Micro-Laser, 2 Pieces of Cable, and 1 Capacitor." @@ -556,17 +556,17 @@ to destroy them and players will be able to make replacements. /obj/item/weapon/circuitboard/pacman/super name = "Circuit Board (SUPERPACMAN-type Generator)" - build_path = "/obj/machinery/power/port_gen/pacman/super" + build_path = /obj/machinery/power/port_gen/pacman/super origin_tech = "programming=3;powerstorage=4;engineering=4" /obj/item/weapon/circuitboard/pacman/mrs name = "Circuit Board (MRSPACMAN-type Generator)" - build_path = "/obj/machinery/power/port_gen/pacman/mrs" + build_path = /obj/machinery/power/port_gen/pacman/mrs origin_tech = "programming=3;powerstorage=5;engineering=5" obj/item/weapon/circuitboard/rdserver name = "Circuit Board (R&D Server)" - build_path = "/obj/machinery/r_n_d/server" + build_path = /obj/machinery/r_n_d/server board_type = "machine" origin_tech = "programming=3" frame_desc = "Requires 2 pieces of cable, and 1 Scanning Module." @@ -576,7 +576,7 @@ obj/item/weapon/circuitboard/rdserver /obj/item/weapon/circuitboard/mechfab name = "Circuit board (Exosuit Fabricator)" - build_path = "/obj/machinery/mecha_part_fabricator" + build_path = /obj/machinery/mecha_part_fabricator board_type = "machine" origin_tech = "programming=3;engineering=3" frame_desc = "Requires 2 Matter Bins, 1 Manipulator, 1 Micro-Laser and 1 Console Screen." @@ -588,7 +588,7 @@ obj/item/weapon/circuitboard/rdserver /obj/item/weapon/circuitboard/podfab name = "Circuit board (Spacepod Fabricator)" - build_path = "/obj/machinery/spod_part_fabricator" //ah fuck my life + build_path = /obj/machinery/spod_part_fabricator //ah fuck my life board_type = "machine" origin_tech = "programming=3;engineering=3" frame_desc = "Requires 3 Matter Bins, 2 Manipulators, 2 Micro-Lasers, and 1 Console Screen." @@ -601,7 +601,7 @@ obj/item/weapon/circuitboard/rdserver /obj/item/weapon/circuitboard/clonepod name = "Circuit board (Clone Pod)" - build_path = "/obj/machinery/clonepod" + build_path = /obj/machinery/clonepod board_type = "machine" origin_tech = "programming=3;biotech=3" frame_desc = "Requires 2 Manipulator, 2 Scanning Module, 2 pieces of cable and 1 Console Screen." @@ -613,7 +613,7 @@ obj/item/weapon/circuitboard/rdserver /obj/item/weapon/circuitboard/clonescanner name = "Circuit board (Cloning Scanner)" - build_path = "/obj/machinery/dna_scannernew" + build_path = /obj/machinery/dna_scannernew board_type = "machine" origin_tech = "programming=2;biotech=2" frame_desc = "Requires 1 Scanning Module, 1 Manipulator, 1 Micro-Laser, 2 pieces of cable and 1 Console Screen." diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 134cc9ff3f5..f4f348bb72a 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -26,13 +26,10 @@ var/list/forbidden_varedit_object_types = list( /client/proc/mod_list_add_ass() //haha var/class = "text" + var/list/allowed_types = list("text", "num","type", "type from text","reference","mob reference", "icon","file","list","edit referenced object","restore to default") 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") - + allowed_types += "marked datum ([holder.marked_datum.type])" + class = input("What kind of variable?","Variable Type") as null|anything in allowed_types if(!class) return @@ -52,6 +49,12 @@ var/list/forbidden_varedit_object_types = list( if("type") var_value = input("Enter type:","Type") as null|anything in typesof(/obj,/mob,/area,/turf) + if("type from text") + var/type_text = input("Enter type:", "Type") as null|message + var_value = text2path(type_text) + if(!var_value) + src << "[type_text] is not a valid path!" + if("reference") var_value = input("Select reference:","Reference") as null|mob|obj|turf|area in world @@ -75,12 +78,10 @@ var/list/forbidden_varedit_object_types = list( /client/proc/mod_list_add(var/list/L) var/class = "text" + var/list/allowed_types = list("text", "num","type", "type from text","reference","mob reference", "icon","file","list","edit referenced object","restore to default") 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") + allowed_types += "marked datum ([holder.marked_datum.type])" + class = input("What kind of variable?","Variable Type") as null|anything in allowed_types if(!class) return @@ -101,6 +102,12 @@ var/list/forbidden_varedit_object_types = list( if("type") var_value = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf) + if("type from text") + var/type_text = input("Enter type:", "Type") as null|message + var_value = text2path(type_text) + if(!var_value) + src << "[type_text] is not a valid path!" + if("reference") var_value = input("Select reference:","Reference") as mob|obj|turf|area in world @@ -173,75 +180,21 @@ var/list/forbidden_varedit_object_types = list( if(variable in locked) if(!check_rights(R_DEBUG)) return - if(isnull(variable)) - usr << "Unable to determine variable type." - - else if(isnum(variable)) - usr << "Variable appears to be NUM." - default = "num" - dir = 1 - - else if(istext(variable)) - usr << "Variable appears to be TEXT." - default = "text" - - else if(isloc(variable)) - usr << "Variable appears to be REFERENCE." - default = "reference" - - else if(isicon(variable)) - usr << "Variable appears to be ICON." - variable = "\icon[variable]" - default = "icon" - - else if(istype(variable,/atom) || istype(variable,/datum)) - usr << "Variable appears to be TYPE." - default = "type" - - else if(istype(variable,/list)) - usr << "Variable appears to be LIST." - default = "list" - - else if(istype(variable,/client)) - usr << "Variable appears to be CLIENT." - default = "cancel" - - else - usr << "Variable appears to be FILE." - default = "file" + default = variable_to_type(variable) usr << "Variable contains: [variable]" - 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(default == "num") + dir = dir2text(variable) if(dir) usr << "If a direction, direction is: [dir]" var/class = "text" + var/list/allowed_types = list("text", "num","type", "type from text", "reference","mob reference", "icon","file","list","edit referenced object","restore to default","DELETE FROM LIST") 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") + allowed_types += "marked datum ([holder.marked_datum.type])" + + class = input("What kind of variable?","Variable Type",default) as null|anything in allowed_types if(!class) return @@ -325,7 +278,7 @@ var/list/forbidden_varedit_object_types = list( if( istype(O,p) ) usr << "It is forbidden to edit this object's variables." return - + if(istype(O, /client) && (param_var_name == "ckey" || param_var_name == "key")) usr << "You cannot edit ckeys on client objects." return @@ -347,44 +300,11 @@ var/list/forbidden_varedit_object_types = list( var_value = O.vars[variable] if(autodetect_class) - if(isnull(var_value)) - usr << "Unable to determine variable type." - class = null + class = variable_to_type(var_value) + if(!class) autodetect_class = null - else if(isnum(var_value)) - usr << "Variable appears to be NUM." - class = "num" + else if(class == "num") dir = 1 - - else if(istext(var_value)) - usr << "Variable appears to be TEXT." - class = "text" - - else if(isloc(var_value)) - usr << "Variable appears to be REFERENCE." - class = "reference" - - else if(isicon(var_value)) - usr << "Variable appears to be ICON." - var_value = "\icon[var_value]" - class = "icon" - - else if(istype(var_value,/atom) || istype(var_value,/datum)) - usr << "Variable appears to be TYPE." - class = "type" - - else if(istype(var_value,/list)) - usr << "Variable appears to be LIST." - class = "list" - - else if(istype(var_value,/client)) - usr << "Variable appears to be CLIENT." - class = "cancel" - - else - usr << "Variable appears to be FILE." - class = "file" - else var/list/names = list() @@ -404,73 +324,23 @@ var/list/forbidden_varedit_object_types = list( var/dir var/default - if(isnull(var_value)) - usr << "Unable to determine variable type." - - else if(isnum(var_value)) - usr << "Variable appears to be NUM." - default = "num" + default = variable_to_type(var_value) + if(default == "num") dir = 1 - - else if(istext(var_value)) - usr << "Variable appears to be TEXT." - default = "text" - - else if(isloc(var_value)) - usr << "Variable appears to be REFERENCE." - default = "reference" - - else if(isicon(var_value)) - usr << "Variable appears to be ICON." + else if(default == "icon") var_value = "\icon[var_value]" - default = "icon" - - else if(istype(var_value,/atom) || istype(var_value,/datum)) - usr << "Variable appears to be TYPE." - default = "type" - - else if(istype(var_value,/list)) - usr << "Variable appears to be LIST." - default = "list" - - else if(istype(var_value,/client)) - usr << "Variable appears to be CLIENT." - default = "cancel" - - else - usr << "Variable appears to be FILE." - default = "file" 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 + dir = dir2text(var_value) if(dir) usr << "If a direction, direction is: [dir]" + var/list/allowed_types = list("text", "num","type","reference","mob reference", "path", "matrix", "icon","file","list","edit referenced object","restore to default") 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])") - 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") + allowed_types += "marked datum ([holder.marked_datum.type])" + + class = input("What kind of variable?","Variable Type",default) as null|anything in allowed_types if(!class) return @@ -485,6 +355,7 @@ var/list/forbidden_varedit_object_types = list( if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])") class = "marked datum" + var/var_as_text = null switch(class) if("list") @@ -507,13 +378,13 @@ var/list/forbidden_varedit_object_types = list( 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=="stat") + else if(variable=="stat") // ow, but I guess I'm glad you're trying to prevent at least one kind of inconsistent state...? This is the VARIABLE EDITOR, I'm not sure we need to worry...? 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((O.vars[variable] == DEAD) && (var_new < DEAD))//Bringing the dead back to life dead_mob_list -= O living_mob_list += O - if((O.vars[variable] < 2) && (var_new == 2))//Kill he + if((O.vars[variable] < DEAD) && (var_new == DEAD))//Kill he living_mob_list -= O dead_mob_list += O O.vars[variable] = var_new @@ -527,6 +398,23 @@ var/list/forbidden_varedit_object_types = list( if(var_new==null) return O.vars[variable] = var_new + if("path") + var/path_text = input("Enter path:", "Path",O.vars[variable]) as null|text + var/var_new = text2path(path_text) + if(!var_new && path_text != null) // So aborting doesn't bother the VVer + usr << "[path_text] does not appear to be a valid path." + return + O.vars[variable] = var_new + + if("matrix") + var/matrix_text = input("Enter a, b, c, d, e, and f, separated by a space.", "Matrix", "1 0 0 0 1 0") as null|text + var/var_new = text2matrix(matrix_text) + if(!var_new && matrix_text != null) + usr << "[matrix_text] is not a valid matrix string." + return + O.vars[variable] = var_new + var_as_text = "matrix([matrix_text])" + 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 @@ -550,7 +438,62 @@ var/list/forbidden_varedit_object_types = list( if("marked datum") O.vars[variable] = holder.marked_datum - log_to_dd("### 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) + if(var_as_text == null) + var_as_text = "[O.vars[variable]]" + log_to_dd("### VarEdit by [src]: [O.type] [variable]=[html_encode("[var_as_text]")]") + log_admin("[key_name(src)] modified [original_name]'s [variable] to [var_as_text]") + message_admins("[key_name_admin(src)] modified [original_name]'s [variable] to [var_as_text]", 1) +// Let's get this all in one place. +// You'll need to take care of setting dir or iconizing the variable yourself once you've called this +/proc/variable_to_type(var/variable) + var/class + if(isnull(variable)) + usr << "Unable to determine variable type." + class = null + else if(isnum(variable)) + usr << "Variable appears to be NUM." + class = "num" + + else if(istext(variable)) + usr << "Variable appears to be TEXT." + class = "text" + + else if(isloc(variable)) + usr << "Variable appears to be REFERENCE." + class = "reference" + + else if(isicon(variable)) + usr << "Variable appears to be ICON." + variable = "\icon[variable]" + class = "icon" + + else if(istype(variable,/matrix)) + usr << "Variable appears to be MATRIX" + class = "matrix" + + else if(istype(variable,/atom) || istype(variable,/datum)) + usr << "Variable appears to be TYPE." + class = "type" + + else if(istype(variable,/list)) + usr << "Variable appears to be LIST." + class = "list" + + else if(istype(variable,/client)) + usr << "Variable appears to be CLIENT." + class = "cancel" + + else if(ispath(variable)) + usr << "Variable appears to be PATH." + class = "path" + + else if(isfile(variable)) + usr << "Variable appears to be FILE." + class = "file" + + else + usr << "Variable type is UNKNOWN." + class = null + + return class \ No newline at end of file