From bcccf41695f1066a0cf3a57bf1bbec32a4c676a4 Mon Sep 17 00:00:00 2001 From: Jordie Date: Fri, 12 Aug 2016 12:07:46 +1000 Subject: [PATCH 1/2] unhardcodes count and display of ores --- code/modules/mining/satchel_ore_boxdm.dm | 58 ++---------------------- 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/code/modules/mining/satchel_ore_boxdm.dm b/code/modules/mining/satchel_ore_boxdm.dm index e53e422653f..1d32b470c79 100644 --- a/code/modules/mining/satchel_ore_boxdm.dm +++ b/code/modules/mining/satchel_ore_boxdm.dm @@ -42,64 +42,12 @@ show_contents(user) /obj/structure/ore_box/proc/show_contents(mob/user) - var/amt_gold = 0 - var/amt_silver = 0 - var/amt_diamond = 0 - var/amt_glass = 0 - var/amt_iron = 0 - var/amt_plasma = 0 - var/amt_uranium = 0 - var/amt_titanium = 0 - var/amt_clown = 0 - var/amt_bluespace = 0 - - for (var/obj/item/weapon/ore/C in contents) - if (istype(C,/obj/item/weapon/ore/diamond)) - amt_diamond++ - if (istype(C,/obj/item/weapon/ore/glass)) - amt_glass++ - if (istype(C,/obj/item/weapon/ore/plasma)) - amt_plasma++ - if (istype(C,/obj/item/weapon/ore/iron)) - amt_iron++ - if (istype(C,/obj/item/weapon/ore/silver)) - amt_silver++ - if (istype(C,/obj/item/weapon/ore/gold)) - amt_gold++ - if (istype(C,/obj/item/weapon/ore/uranium)) - amt_uranium++ - if (istype(C,/obj/item/weapon/ore/bananium)) - amt_clown++ - if (istype(C,/obj/item/weapon/ore/titanium)) - amt_titanium++ - if (istype(C,/obj/item/weapon/ore/bluespace_crystal)) - amt_bluespace++ - var/dat = text("The contents of the ore box reveal...
") - if (amt_gold) - dat += text("Gold ore: [amt_gold]
") - if (amt_silver) - dat += text("Silver ore: [amt_silver]
") - if (amt_iron) - dat += text("Metal ore: [amt_iron]
") - if (amt_glass) - dat += text("Sand: [amt_glass]
") - if (amt_diamond) - dat += text("Diamond ore: [amt_diamond]
") - if (amt_plasma) - dat += text("Plasma ore: [amt_plasma]
") - if (amt_uranium) - dat += text("Uranium ore: [amt_uranium]
") - if (amt_clown) - dat += text("Titanium ore: [amt_titanium]
") - if (amt_titanium) - dat += text("Bananium ore: [amt_clown]
") - if (amt_bluespace) - dat += text("Bluespace crystals: [amt_bluespace]
") - + var/list/oretypes = uniqueList(contents) + for(var/obj/item/weapon/ore/O in oretypes) + dat += "[capitalize(O.name)]: [count_by_type(contents, O.type)]
" dat += text("

Empty box") user << browse("[dat]", "window=orebox") - return /obj/structure/ore_box/proc/dump_contents() for (var/obj/item/weapon/ore/O in contents) From c0a749d6b11a2686e6519617ba01c4e4ed4b0447 Mon Sep 17 00:00:00 2001 From: Jordie0608 Date: Sat, 13 Aug 2016 15:41:57 +1000 Subject: [PATCH 2/2] properly uniques list display --- code/modules/mining/satchel_ore_boxdm.dm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/modules/mining/satchel_ore_boxdm.dm b/code/modules/mining/satchel_ore_boxdm.dm index 1d32b470c79..1e00a046de0 100644 --- a/code/modules/mining/satchel_ore_boxdm.dm +++ b/code/modules/mining/satchel_ore_boxdm.dm @@ -43,9 +43,12 @@ /obj/structure/ore_box/proc/show_contents(mob/user) var/dat = text("The contents of the ore box reveal...
") - var/list/oretypes = uniqueList(contents) - for(var/obj/item/weapon/ore/O in oretypes) - dat += "[capitalize(O.name)]: [count_by_type(contents, O.type)]
" + var/list/oretypes = list() + for(var/obj/item/weapon/ore/O in contents) + oretypes |= O.type + for(var/i in oretypes) + var/obj/item/weapon/ore/T = locate(i) in contents + dat += "[capitalize(T.name)]: [count_by_type(contents, T.type)]
" dat += text("

Empty box") user << browse("[dat]", "window=orebox")