Files
Citadel-Station-13-RP/code/__HELPERS/lists/string.dm
Zandario ed05e01a95 __HELPERS Cleaning and other things I decided to do. (#4584)
* Schizoposting

* The Crungly

* Tabbin' the JSON y'all

* Strings
2022-10-21 01:56:59 -07:00

33 lines
740 B
Plaintext

/**
* Returns a list in plain english as a string.
*/
/proc/english_list(list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" )
var/total = input.len
if (!total)
return "[nothing_text]"
else if (total == 1)
return "[input[1]]"
else if (total == 2)
return "[input[1]][and_text][input[2]]"
else
var/output = ""
var/index = 1
while (index < total)
if (index == total - 1)
comma_text = final_comma_text
output += "[input[index]][comma_text]"
index++
return "[output][and_text][input[index]]"
/**
* Removes a string from a list.
*/
/proc/remove_strings_from_list(string, list/L)
if(!LAZYLEN(L) || !string)
return
while(string in L)
L -= string
return L