mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Improves the spawn command (#13063)
* Improves the spawn command * fix description
This commit is contained in:
@@ -388,6 +388,15 @@ var/global/list/watt_suffixes = list("W", "KW", "MW", "GW", "TW", "PW", "EW", "Z
|
|||||||
i++
|
i++
|
||||||
return "[format_num(number)] [watt_suffixes[i]]"
|
return "[format_num(number)] [watt_suffixes[i]]"
|
||||||
|
|
||||||
|
//Returns 1 if [text] ends with [suffix]
|
||||||
|
//Example: text_ends_with("Woody got wood", "dy got wood") returns 1
|
||||||
|
// text_ends_with("Woody got wood", "d") returns 1
|
||||||
|
// text_ends_with("Woody got wood", "Wood") returns 0
|
||||||
|
proc/text_ends_with(text, suffix)
|
||||||
|
if(length(suffix) > length(text))
|
||||||
|
return FALSE
|
||||||
|
|
||||||
|
return (copytext(text, length(text) - length(suffix) + 1) == suffix)
|
||||||
|
|
||||||
// Custom algorithm since stackoverflow is full of complete garbage and even the MS algorithm sucks.
|
// Custom algorithm since stackoverflow is full of complete garbage and even the MS algorithm sucks.
|
||||||
// Uses recursion, in places.
|
// Uses recursion, in places.
|
||||||
|
|||||||
@@ -1240,7 +1240,7 @@ var/global/floorIsLava = 0
|
|||||||
*/
|
*/
|
||||||
/datum/admins/proc/spawn_atom(var/object as text)
|
/datum/admins/proc/spawn_atom(var/object as text)
|
||||||
set category = "Debug"
|
set category = "Debug"
|
||||||
set desc = "(atom path) Spawn an atom"
|
set desc = "(atom path) Spawn an atom. Finish path with a period to hide subtypes"
|
||||||
set name = "Spawn"
|
set name = "Spawn"
|
||||||
|
|
||||||
if(!check_rights(R_SPAWN))
|
if(!check_rights(R_SPAWN))
|
||||||
@@ -1248,10 +1248,18 @@ var/global/floorIsLava = 0
|
|||||||
|
|
||||||
var/list/matches = new()
|
var/list/matches = new()
|
||||||
|
|
||||||
|
if(text_ends_with(object, ".")) //Path ends with a dot - DO NOT include subtypes
|
||||||
|
object = copytext(object, 1, length(object)) //Remove the dot
|
||||||
|
|
||||||
|
for(var/path in typesof(/atom))
|
||||||
|
if(text_ends_with("[path]", object))
|
||||||
|
matches += path
|
||||||
|
else //Include subtypes
|
||||||
for(var/path in typesof(/atom))
|
for(var/path in typesof(/atom))
|
||||||
if(findtext("[path]", object))
|
if(findtext("[path]", object))
|
||||||
matches += path
|
matches += path
|
||||||
|
|
||||||
|
|
||||||
if(matches.len==0)
|
if(matches.len==0)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
6
html/changelogs/unid-ta.yml
Normal file
6
html/changelogs/unid-ta.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
author: Unid
|
||||||
|
|
||||||
|
delete-after: True
|
||||||
|
|
||||||
|
changes:
|
||||||
|
- tweak: "When using the 'spawn' admin command, you can place a period at the end of the path to prevent subtypes of the path from being listed. For example: 'spawn /mob/living/carbon/human.' spawns a human without bringing up any lists."
|
||||||
Reference in New Issue
Block a user