diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index d633e142fbd..8421dbf7120 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -302,6 +302,9 @@ GLOBAL_LIST_INIT(view_runtimes_verbs, list( spawn(1) // This setting exposes the profiler for people with R_VIEWRUNTIMES. They must still have it set in cfg/admin.txt control_freak = 0 + if(is_connecting_from_localhost()) + verbs += /client/proc/export_current_character + /client/proc/remove_admin_verbs() verbs.Remove( @@ -1055,3 +1058,12 @@ GLOBAL_LIST_INIT(view_runtimes_verbs, list( show_blurb(about_to_be_banned, 15, message, null, "center", "center", message_color, null, null, 1) log_admin("[key_name(src)] sent an admin alert to [key_name(about_to_be_banned)] with custom message [message].") message_admins("[key_name(src)] sent an admin alert to [key_name(about_to_be_banned)] with custom message [message].") + + +/client/proc/export_current_character() + set name = "Export Character DMI/JSON" + set category = "Admin" + + if(ishuman(mob)) + var/mob/living/carbon/human/H = mob + H.export_dmi_json() diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm index eb8b65a9163..fb41d6e1bf9 100644 --- a/code/modules/mob/living/carbon/human/human_mob.dm +++ b/code/modules/mob/living/carbon/human/human_mob.dm @@ -1254,6 +1254,46 @@ sec_hud_set_ID() + +/mob/living/carbon/human/proc/export_dmi_json() + var/filename = clean_input("filename", "filename", "my_character") + + if(filename == "") + return + + var/maxCount = 10 + var/curCount = 0 + var/dmipath = "data/exports/characters/[filename].dmi" + log_world("saving icon to [filename]") + var/icon/allDirs = null + + var/list/directions = list(SOUTH, NORTH, EAST, WEST) + for(var/d in directions) + var/icon/new_icon + for(var/i = 0; i < maxCount; i++) + sleep(5) + curCount = i + new_icon = getFlatIcon(src, defdir=d) + if(new_icon != null) + break + + if(new_icon == null) + log_world("ran [curCount] times and could not find icon") + else + log_world("ran [curCount] times and found icon") + if(allDirs == null) + allDirs = icon(new_icon, "", d) + else + allDirs.Insert(new_icon, "", d) + + fcopy(allDirs, dmipath) + log_world("saved icon to [dmipath]") + + var/jsonpath = "data/exports/characters/[filename].json" + var/json = json_encode(serialize()) + text2file(json, jsonpath) + log_world("saved json to [jsonpath]") + /** * Change a mob's species. *