mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-18 18:44:48 +01:00
Adds subtypesof helper proc
It returns a list containing all subtypes of the object path given to it, but not the object path itself. This only exists because typesof(/obj/item/thing) - /obj/item/thing is used quite often. Also adds a "/" to the start of a lot of the list helper procs that did not start with one.
This commit is contained in:
+14
-10
@@ -31,7 +31,7 @@
|
||||
return "[output][and_text][input[index]]"
|
||||
|
||||
//Returns list element or null. Should prevent "index out of bounds" error.
|
||||
proc/listgetindex(var/list/list,index)
|
||||
/proc/listgetindex(var/list/list,index)
|
||||
if(istype(list) && list.len)
|
||||
if(isnum(index))
|
||||
if(InRange(index,1,list.len))
|
||||
@@ -40,19 +40,19 @@ proc/listgetindex(var/list/list,index)
|
||||
return list[index]
|
||||
return
|
||||
|
||||
proc/islist(list/list)
|
||||
/proc/islist(list/list)
|
||||
if(istype(list))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//Return either pick(list) or null if list is not of type /list or is empty
|
||||
proc/safepick(list/list)
|
||||
/proc/safepick(list/list)
|
||||
if(!islist(list) || !list.len)
|
||||
return
|
||||
return pick(list)
|
||||
|
||||
//Checks if the list is empty
|
||||
proc/isemptylist(list/list)
|
||||
/proc/isemptylist(list/list)
|
||||
if(!list.len)
|
||||
return 1
|
||||
return 0
|
||||
@@ -65,13 +65,13 @@ proc/isemptylist(list/list)
|
||||
return 0
|
||||
|
||||
//Empties the list by setting the length to 0. Hopefully the elements get garbage collected
|
||||
proc/clearlist(list/list)
|
||||
/proc/clearlist(list/list)
|
||||
if(istype(list))
|
||||
list.len = 0
|
||||
return
|
||||
|
||||
//Removes any null entries from the list
|
||||
proc/listclearnulls(list/list)
|
||||
/proc/listclearnulls(list/list)
|
||||
if(istype(list))
|
||||
while(null in list)
|
||||
list -= null
|
||||
@@ -504,7 +504,7 @@ proc/dd_sortedObjectList(list/incoming)
|
||||
return sorted_list
|
||||
*/
|
||||
|
||||
proc/dd_sortedtextlist(list/incoming, case_sensitive = 0)
|
||||
/proc/dd_sortedtextlist(list/incoming, case_sensitive = 0)
|
||||
// Returns a new list with the text values sorted.
|
||||
// Use binary search to order by sortValue.
|
||||
// This works by going to the half-point of the list, seeing if the node in question is higher or lower cost,
|
||||
@@ -563,16 +563,20 @@ proc/dd_sortedtextlist(list/incoming, case_sensitive = 0)
|
||||
return sorted_text
|
||||
|
||||
|
||||
proc/dd_sortedTextList(list/incoming)
|
||||
/proc/dd_sortedTextList(list/incoming)
|
||||
var/case_sensitive = 1
|
||||
return dd_sortedtextlist(incoming, case_sensitive)
|
||||
|
||||
/proc/subtypesof(var/path) //Returns a list containing all subtypes of the given path, but not the given path itself.
|
||||
if(!path || !ispath(path))
|
||||
return
|
||||
return (typesof(path) - path)
|
||||
|
||||
datum/proc/dd_SortValue()
|
||||
/datum/proc/dd_SortValue()
|
||||
return "[src]"
|
||||
|
||||
/obj/machinery/dd_SortValue()
|
||||
return "[sanitize(name)]"
|
||||
|
||||
/obj/machinery/camera/dd_SortValue()
|
||||
return "[c_tag]"
|
||||
return "[c_tag]"
|
||||
|
||||
Reference in New Issue
Block a user