Add DMI/JSON export to local client admins. (#23947)

* Add DMI/JSON export to local client admins.

* switch to log_world, add if paren
This commit is contained in:
warriorstar-orion
2024-03-01 08:59:56 -05:00
committed by GitHub
parent 0a2669f708
commit e1614b9ecb
2 changed files with 52 additions and 0 deletions
+12
View File
@@ -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()
@@ -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.
*