Adds a cargo crate spawning tool for admins (#20220)

* Allows admins to create cargo crates

* AA and Miravel review

* remove debug text

* AA review

* Oops

* sirryan review

* sirryan review 2

* atom to turf
This commit is contained in:
Contrabang
2023-02-14 00:21:58 -05:00
committed by GitHub
parent f5db427bc8
commit 93f26cf5aa
4 changed files with 82 additions and 23 deletions

View File

@@ -1190,3 +1190,50 @@ Traitors and the like can also be revived with the previous role mostly intact.
if(!source)
return
REMOVE_TRAIT(D, chosen_trait, source)
/client/proc/create_crate(object as text)
set name = "Create Crate"
set desc = "Spawn a crate from a supplypack datum. Append a period to the text in order to exclude subtypes of paths matching the input."
set category = "Event"
if(!check_rights(R_SPAWN))
return
var/list/types = SSeconomy.supply_packs
var/list/matches = list()
var/include_subtypes = TRUE
if(copytext(object, -1) == ".")
include_subtypes = FALSE
object = copytext(object, 1, -1)
if(include_subtypes)
for(var/path in types)
if(findtext("[path]", object))
matches += path
else
var/needle_length = length(object)
for(var/path in types)
if(copytext("[path]", -needle_length) == object)
matches += path
if(!length(matches))
return
var/chosen = input("Select a supply crate type", "Create Crate", matches[1]) as null|anything in matches
if(!chosen)
return
var/datum/supply_packs/the_pack = new chosen()
var/spawn_location = get_turf(usr)
if(!spawn_location)
return
var/obj/structure/closet/crate/crate = the_pack.create_package(spawn_location)
crate.admin_spawned = TRUE
for(var/atom/A in crate.contents)
A.admin_spawned = TRUE
qdel(the_pack)
log_admin("[key_name(usr)] created a '[chosen]' crate at ([usr.x],[usr.y],[usr.z])")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Create Crate") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!