mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-16 09:34:52 +01:00
spawn verb port (#19360)
This commit is contained in:
+29
-20
@@ -1024,33 +1024,42 @@ ADMIN_VERB(spawn_plant, R_SPAWN, "Spawn Plant", "Spawn a spreading plant effect.
|
||||
new /obj/effect/plant(get_turf(user_mob), SSplants.seeds[seedtype])
|
||||
log_admin("[key_name(user)] spawned [seedtype] vines at ([user_mob.x],[user_mob.y],[user_mob.z])")
|
||||
|
||||
ADMIN_VERB(spawn_atom, R_SPAWN, "Spawn", "(atom path) Spawn an atom", ADMIN_CATEGORY_DEBUG_GAME, object as text)
|
||||
var/list/types = typesof(/atom)
|
||||
var/list/matches = new()
|
||||
ADMIN_VERB(spawn_atom, R_SPAWN, "Spawn", "(atom path) Spawn an atom", ADMIN_CATEGORY_DEBUG_GAME, object as text|null)
|
||||
var/static/list/atom_types
|
||||
if(isnull(atom_types))
|
||||
atom_types = subtypesof(/atom)
|
||||
|
||||
for(var/path in types)
|
||||
if(findtext("[path]", object))
|
||||
matches += path
|
||||
var/chosen_path = null
|
||||
var/list/preparsed = null
|
||||
if(object)
|
||||
preparsed = splittext(object, ":")
|
||||
var/list/matches = filter_fancy_list(atom_types, preparsed[1])
|
||||
if(length(matches) == 1)
|
||||
chosen_path = matches[1]
|
||||
|
||||
if(matches.len==0)
|
||||
if(!chosen_path)
|
||||
var/datum/spawn_menu/menu = user.holder.spawn_menu
|
||||
if(!menu)
|
||||
menu = new()
|
||||
user.holder.spawn_menu = menu
|
||||
menu.init_value = object
|
||||
menu.tgui_interact(user.mob)
|
||||
feedback_add_details("admin_verb","SA")
|
||||
return
|
||||
|
||||
var/chosen
|
||||
if(matches.len==1)
|
||||
chosen = matches[1]
|
||||
else
|
||||
chosen = tgui_input_list(user, "Select an atom type", "Spawn Atom", matches)
|
||||
if(!chosen)
|
||||
return
|
||||
var/amount = 1
|
||||
if(length(preparsed) > 1)
|
||||
amount = clamp(text2num(preparsed[2]), 1, ADMIN_SPAWN_CAP)
|
||||
|
||||
var/mob/user_mob = user.mob
|
||||
if(ispath(chosen,/turf))
|
||||
var/turf/T = get_turf(user_mob.loc)
|
||||
T.ChangeTurf(chosen)
|
||||
var/turf/target_turf = get_turf(user.mob)
|
||||
if(ispath(chosen_path, /turf))
|
||||
target_turf.ChangeTurf(chosen_path)
|
||||
else
|
||||
new chosen(user_mob.loc)
|
||||
for(var/i in 1 to amount)
|
||||
var/atom/spawned = new chosen_path(target_turf)
|
||||
spawned.flags |= ADMIN_SPAWNED
|
||||
|
||||
log_and_message_admins("spawned [chosen] at ([user_mob.x],[user_mob.y],[user_mob.z])")
|
||||
log_and_message_admins("spawned [amount] x [chosen_path] at [AREACOORD(user.mob)]", user)
|
||||
feedback_add_details("admin_verb","SA") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
ADMIN_VERB(show_traitor_panel, R_ADMIN|R_FUN|R_EVENT, "Show Traitor Panel", "Edit mobs's memory and role", ADMIN_CATEGORY_EVENTS, mob/M in GLOB.mob_list)
|
||||
|
||||
@@ -32,6 +32,7 @@ GLOBAL_PROTECT(href_token)
|
||||
var/datum/filter_editor/filteriffic
|
||||
var/datum/particle_editor/particle_test
|
||||
var/datum/whitelist_editor/whitelist_editor
|
||||
var/datum/spawn_menu/spawn_menu
|
||||
var/datum/spawnpanel/spawn_panel
|
||||
|
||||
/// A lazylist of tagged datums, for quick reference with the View Tags verb
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/datum/spawn_menu
|
||||
/// Does the menu default to a regex prefix?
|
||||
var/regex_search = FALSE
|
||||
/// Does the search include atom names?
|
||||
var/name_search = TRUE
|
||||
/// Should we display full typepaths or the condensed versions?
|
||||
var/fancy_types = TRUE
|
||||
/// Should abstract types be included in the search?
|
||||
var/include_abstracts = FALSE
|
||||
/// Initial search value from the latest command
|
||||
var/init_value = null
|
||||
|
||||
/datum/spawn_menu/tgui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if (!ui)
|
||||
ui = new(user, src, "SpawnSearch")
|
||||
ui.open()
|
||||
|
||||
/datum/spawn_menu/tgui_state(mob/user)
|
||||
return ADMIN_STATE(R_SPAWN)
|
||||
|
||||
/datum/spawn_menu/tgui_act(action, params, datum/tgui/ui)
|
||||
if (..() || !check_rights_for(ui.user.client, R_SPAWN))
|
||||
return FALSE
|
||||
|
||||
switch (action)
|
||||
if ("setRegexSearch")
|
||||
regex_search = params["regexSearch"]
|
||||
return TRUE
|
||||
|
||||
if ("setNameSearch")
|
||||
name_search = params["searchNames"]
|
||||
return TRUE
|
||||
|
||||
if ("setFancyTypes")
|
||||
fancy_types = params["fancyTypes"]
|
||||
return TRUE
|
||||
|
||||
if ("setIncludeAbstracts")
|
||||
include_abstracts = params["includeAbstracts"]
|
||||
return TRUE
|
||||
|
||||
if ("spawn")
|
||||
var/path = text2path(params["type"])
|
||||
if (!path)
|
||||
return TRUE
|
||||
var/amount = clamp(text2num(params["amount"]) || 1, 1, ADMIN_SPAWN_CAP)
|
||||
var/turf/target_turf = get_turf(ui.user)
|
||||
if(ispath(path, /turf))
|
||||
target_turf.ChangeTurf(path)
|
||||
else
|
||||
for(var/i in 1 to amount)
|
||||
var/atom/spawned = new path(target_turf)
|
||||
spawned.flags |= ADMIN_SPAWNED
|
||||
|
||||
log_admin("[key_name(ui.user)] spawned [amount] x [path] at [AREACOORD(ui.user)]")
|
||||
SStgui.close_uis(src)
|
||||
return TRUE
|
||||
|
||||
if ("cancel")
|
||||
SStgui.close_uis(src)
|
||||
return TRUE
|
||||
|
||||
/datum/spawn_menu/tgui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["initValue"] = init_value
|
||||
data["searchNames"] = name_search
|
||||
data["regexSearch"] = regex_search
|
||||
data["fancyTypes"] = fancy_types
|
||||
data["includeAbstracts"] = include_abstracts
|
||||
return data
|
||||
|
||||
/datum/spawn_menu/ui_assets(mob/user)
|
||||
return list(
|
||||
get_asset_datum(/datum/asset/json/spawn_menu),
|
||||
)
|
||||
|
||||
/datum/asset/json/spawn_menu
|
||||
name = "spawn_menu_atom_data"
|
||||
|
||||
/datum/asset/json/spawn_menu/generate()
|
||||
var/list/data = list()
|
||||
var/static/list/types_list
|
||||
if (isnull(types_list))
|
||||
var/list/local_types = list()
|
||||
for (var/atom/atom_type as anything in subtypesof(/atom))
|
||||
local_types[atom_type] = atom_type::name || ""
|
||||
types_list = local_types
|
||||
data["types"] = types_list
|
||||
data["abstractTypes"] = get_abstract_types()
|
||||
data["fancyTypes"] = GLOB.fancy_type_replacements
|
||||
return data
|
||||
Reference in New Issue
Block a user