diff --git a/code/_helpers/_lists.dm b/code/_helpers/_lists.dm index 497c1be907..bc6b46ea18 100644 --- a/code/_helpers/_lists.dm +++ b/code/_helpers/_lists.dm @@ -25,8 +25,8 @@ if(2) return "[input[1]][and_text][input[2]]" else return "[jointext(input, comma_text, 1, -1)][final_comma_text][and_text][input[input.len]]" -//Returns a list that counts equal-ish items, outputting count and item names, optionally with icons and specific determiners -/proc/counting_english_list(var/list/input, output_icons = TRUE, determiners = DET_NONE, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "") +//Returns a newline-separated list that counts equal-ish items, outputting count and item names, optionally with icons and specific determiners +/proc/counting_english_list(var/list/input, output_icons = TRUE, determiners = DET_NONE, nothing_text = "nothing", line_prefix = "\t", first_item_prefix = "\n", last_item_suffix = "\n", and_text = "\n", comma_text = "\n", final_comma_text = "") var/list/counts = list() // counted input items var/list/items = list() // actual objects for later reference (for icons and formatting) @@ -41,10 +41,11 @@ // assemble the output list var/list/out = list() + var/i = 0 for(var/item in items) var/name = "[item]" var/count = counts[name] - var/item_str = "" + var/item_str = line_prefix if(count > 1) item_str += "[count]x " @@ -61,11 +62,22 @@ else // non-atoms use plain string conversion item_str += name + + if(i == 0) + item_str = first_item_prefix + item_str + if(i == items.len - 1) + item_str = item_str + last_item_suffix + out.Add(item_str) + i++ // finally return the list using regular english_list builder return english_list(out, nothing_text, and_text, comma_text, final_comma_text) +//A "preset" for counting_english_list that displays the list "inline" (comma separated) +/proc/inline_counting_english_list(var/list/input, output_icons = TRUE, determiners = DET_NONE, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "", line_prefix = "", first_item_prefix = "", last_item_suffix = "") + return counting_english_list(input, output_icons, determiners, nothing_text, and_text, comma_text, final_comma_text) + //Returns list element or null. Should prevent "index out of bounds" error. proc/listgetindex(var/list/list,index) if(istype(list) && list.len) diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index c779c80aa8..c38e5555f0 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -74,7 +74,7 @@ to_chat(user, "It is full.") if(!src.opened && isobserver(user)) - to_chat(user, "It contains: [counting_english_list(contents)].") + to_chat(user, "It contains: [counting_english_list(contents)]") /obj/structure/closet/CanPass(atom/movable/mover, turf/target) if(wall_mounted)