// /client/proc/debug_variables(datum/D in world) set category = "Debug" set name = "View Variables" //set src in world var/title = "" var/body = "" if (istype(D, /atom)) var/atom/A = D title = "[A.name][src.holder.level >= LEVEL_SHITGUY ? " (\ref[A])" : ""] = [A.type]" #ifdef VARSICON if (A.icon) body += debug_variable("icon", new/icon(A.icon, A.icon_state, A.dir), 0) #endif title = "[D][src.holder.level >= LEVEL_SHITGUY ? " (\ref[D])" : ""] = [D.type]" 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) body += " - Edit (A) (S)" if (istype(D.vars[V], /datum) && src.holder.level >= LEVEL_CODER) body += " (P)" body += "
" var/html = "" if (title) html += "[title]" html += {""} html += "" html += "Refresh" if (src.holder.level >= LEVEL_CODER) html += " | Call Proc
" if (istype(D, /atom)) html += "Jump To" if (ismob(D) || isobj(D)) html += " | Get" if (ismob(D)) html += " | Player Options" html += "
<<== " html += "<= " html += "Set Direction " html += "=> " html += "==>>
" html += "
(A) = Edit all entities of same type
(S) = Set this var on all entities of same type
(P) = Call Proc
" html += body html += "" usr << browse(html, "window=variables\ref[D]") return /client/proc/debug_variable(name, value, level) var/html = "" 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 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 (istype(value, /datum)) var/datum/D = value var/dname = null if ("name" in D.vars) dname = " (" + D.vars["name"] + ")" html += "[name][src.holder.level >= LEVEL_SHITGUY ? " \ref[value]" : ""] = [D.type][dname]" else if (istype(value, /client)) var/client/C = value html += "[name][src.holder.level >= LEVEL_SHITGUY ? " \ref[value]" : ""] = [C] [C.type]" else if (islist(value)) var/list/L = value html += "[name] = /list ([L.len])" if (!isnull(L) && L.len > 0 && !(name == "underlays" || name == "overlays" || name == "vars" || name == "verbs" || L.len > 500)) // not sure if this is completely right... if (0) // (L.vars.len > 0) html += "
      " for (var/entry in L) html += debug_variable(entry, L[entry], level + 1) html += "
    " else html += "" else html += "[name] = [value]" html += "
  • " return html /client/Topic(href, href_list, hsrc) if (href_list["Refresh"]) src.debug_variables(locate(href_list["Refresh"])) if (href_list["JumpToThing"]) var/atom/A = locate(href_list["JumpToThing"]) if (istype(A)) src.jumptoturf(get_turf(A)) return if (href_list["GetThing"]) var/atom/A = locate(href_list["GetThing"]) if (ismob(A) || isobj(A)) src.cmd_admin_get_mobject(A) return if (href_list["PlayerOptions"]) var/mob/M = locate(href_list["PlayerOptions"]) if (istype(M)) src.holder.playeropt(M) return if (href_list["SetDirection"]) var/atom/A = locate(href_list["SetDirection"]) if (istype(A)) var/new_dir = href_list["DirectionToSet"] if (new_dir == "L90") A.dir = turn(A.dir, 90) boutput(src, "Turned [A] 90° to the left: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "L45") A.dir = turn(A.dir, 45) boutput(src, "Turned [A] 45° to the left: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "R90") A.dir = turn(A.dir, -90) boutput(src, "Turned [A] 90° to the right: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "R45") A.dir = turn(A.dir, -45) boutput(src, "Turned [A] 45° to the right: direction is now [uppertext(dir2text(A.dir))].") else var/list/english_dirs = list("NORTH", "NORTHEAST", "EAST", "SOUTHEAST", "SOUTH", "SOUTHWEST", "WEST", "NORTHWEST") new_dir = input(src, "Choose a direction for [A] to face.", "Selection", "NORTH") as null|anything in english_dirs if (new_dir) A.dir = text2dir(new_dir) boutput(src, "Set [A]'s direction to [new_dir]") return if (href_list["CallProc"]) doCallProc(locate(href_list["CallProc"])) return if (href_list["Vars"]) if (href_list["varToEdit"]) modify_variable(locate(href_list["Vars"]), href_list["varToEdit"]) else if (href_list["varToEditAll"]) modify_variable(locate(href_list["Vars"]), href_list["varToEditAll"], 1) else if (href_list["setAll"]) set_all(locate(href_list["Vars"]), href_list["setAll"]) else if (href_list["procCall"]) var/datum/D = locate(href_list["Vars"]) if (D) var/datum/C = D.vars[href_list["procCall"]] if (istype(C, /datum)) doCallProc(C) else debug_variables(locate(href_list["Vars"])) else ..() /client/proc/set_all(datum/D, variable) if(!variable || !D || !(variable in D.vars)) return if(!src.holder) boutput(src, "Only administrators may use this command.") return var/var_value = D.vars[variable] for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = var_value sleep(1) /client/proc/modify_variable(datum/D, variable, set_global = 0) if(!variable || !D || !(variable in D.vars)) return var/list/locked = list("vars", "key", "ckey", "client", "holder") if(!src.holder) boutput(src, "Only administrators may use this command.") return var/default var/var_value = D.vars[variable] var/dir if (locked.Find(variable) && !(src.holder.rank in list("Host", "Coder", "Shit Person"))) boutput(usr, "You do not have access to edit this variable!") return //Let's prevent people from promoting themselves, yes? var/list/locked_type = list(/datum/admins) //Short list - might be good if there are more objects that oughta be paws-off if(!(src.holder.rank in list("Host", "Coder")) && D.type in locked_type ) boutput(usr, "You're not allowed to edit [D.type] for security reasons!") logTheThing("admin", usr, null, "tried to varedit [D.type] but was denied!") logTheThing("diary", usr, null, "tried to varedit [D.type] but was denied!", "admin") message_admins("[key_name(usr)] tried to varedit [D.type] but was denied.") //If someone tries this let's make sure we all know it. return if (isnull(var_value)) boutput(usr, "Unable to determine variable type.") else if (isnum(var_value)) boutput(usr, "Variable appears to be NUM.") default = "num" dir = 1 else if (is_valid_color_string(var_value)) boutput(usr, "Variable appears to be COLOR.") default = "color" else if (istext(var_value)) boutput(usr, "Variable appears to be TEXT.") default = "text" else if (isloc(var_value)) boutput(usr, "Variable appears to be REFERENCE.") default = "reference" else if (isicon(var_value)) boutput(usr, "Variable appears to be ICON.") //var_value = "[bicon(var_value)]" default = "icon" else if (istype(var_value,/atom) || istype(var_value,/datum)) boutput(usr, "Variable appears to be TYPE.") default = "type" else if (islist(var_value)) boutput(usr, "Variable appears to be LIST.") default = "list" else if (istype(var_value,/client)) boutput(usr, "Variable appears to be CLIENT.") default = "cancel" else boutput(usr, "Variable appears to be FILE.") default = "file" boutput(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) boutput(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","reference","mob reference","turf by coordinates","reference picker","new instance of a type","icon","file","color","list","edit referenced object","create new list","restore to default") if(!class) return var/original_name if (!istype(D, /atom)) original_name = "[src.holder.level >= LEVEL_SHITGUY ? "\ref[D] " : ""]([D])" else original_name = D:name var/tmp/oldVal = D.vars[variable] switch(class) if("list") mod_list(D.vars[variable]) //return <- Way to screw up logging if("restore to default") if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = initial(x:vars[variable]) else D.vars[variable] = initial(D.vars[variable]) if("edit referenced object") return .(D.vars[variable]) if("create new list") if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = list() else D.vars[variable] = list() if("text") var/theInput = input("Enter new text:","Text", D.vars[variable]) as null|text if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("num") var/theInput = input("Enter new number:","Num", D.vars[variable]) as null|num if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("type") var/theInput = input("Enter type:","Type",D.vars[variable]) in null|typesof(/obj,/mob,/area,/turf) if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("reference") var/theInput = input("Select reference:","Reference", D.vars[variable]) as null|mob|obj|turf|area in world if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("mob reference") var/theInput = input("Select reference:","Reference", D.vars[variable]) as null|mob in world if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("file") var/theInput = input("Pick file:","File",D.vars[variable]) as null|file if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("icon") var/theInput = input("Pick icon:","Icon",D.vars[variable]) as null|icon if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("color") var/theInput = input("Pick color:","Color",D.vars[variable]) as null|color if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput else D.vars[variable] = theInput if("turf by coordinates") var/x = input("X coordinate", "Set to turf at \[_, ?, ?\]", 1) as num var/y = input("Y coordinate", "Set to turf at \[[x], _, ?\]", 1) as num var/z = input("Z coordinate", "Set to turf at \[[x], [y], _\]", 1) as num var/turf/T = locate(x, y, z) if (istype(T)) if (set_global) for (var/datum/q in world) if (!istype(q, D.type)) continue q.vars[variable] = T else D.vars[variable] = T else boutput(usr, "Invalid coordinates!") return if("reference picker") boutput(usr, "Click the mob, object or turf to use as a reference.") var/mob/M = usr if (istype(M)) var/datum/targetable/refpicker/R if (set_global) R = new /datum/targetable/refpicker/global() else R = new() R.target = D R.varname = variable M.targeting_spell = R M.update_cursor() return if ("new instance of a type") boutput(usr, "Type part of the path of type of thing to instantiate.") var/typename = input("Part of type path.", "Part of type path.", "/obj") as null|text if (typename) var/basetype = /obj if (src.holder.rank in list("Host", "Coder", "Shit Person")) basetype = /datum var/match = get_one_match(typename, basetype) if (match) if (set_global) for (var/datum/x in world) if (!istype(x, D.type)) continue x.vars[variable] = new match(x) else D.vars[variable] = new match(D) else return logTheThing("admin", src, null, "modified [original_name]'s [variable] to [D.vars[variable]]" + (set_global ? " on all entities of same type" : "")) logTheThing("diary", src, null, "modified [original_name]'s [variable] to [D.vars[variable]]" + (set_global ? " on all entities of same type" : ""), "admin") message_admins("[key_name(src)] modified [original_name]'s [variable] to [D.vars[variable]]" + (set_global ? " on all entities of same type" : ""), 1) spawn(0) if (istype(D, /datum)) D.onVarChanged(variable, oldVal, D.vars[variable]) src.debug_variables(D) /mob/proc/Delete(atom/A in view()) set category = "Debug" switch (alert("Are you sure you wish to delete \the [A.name] at ([A.x],[A.y],[A.z]) ?", "Admin Delete Object","Yes","No")) if("Yes") logTheThing("admin", usr, null, "deleted [A.name] at ([showCoords(A.x, A.y, A.z)])") logTheThing("diary", usr, null, "deleted [A.name] at ([showCoords(A.x, A.y, A.z, 1)])", "admin")