From 2abbbc7a40345a80bbb116f384f68a6b63766ac2 Mon Sep 17 00:00:00 2001 From: FlimFlamm Date: Wed, 8 Feb 2017 10:08:06 -0400 Subject: [PATCH] This commit removes the loop used to check contents and instead uses W.contents.len in order to compare the ccurrent number of items in the crayon box against it's max storage capacity (6) to ensure the crayon box is full. Also better usage of returns in order to preserve indentation on code and make it more readable. --- .../crates_lockers/closets/cardboardbox.dm | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm index 63f311d92f3..39f2cc93789 100644 --- a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm +++ b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm @@ -66,32 +66,30 @@ qdel(src) return if(istype(W, /obj/item/weapon/storage/fancy/crayons)) - var/list/contents = W.contents - var/crayoncount = 0 - for(var/C in contents) - if(istype(C, /obj/item/toy/crayon)) - crayoncount += 1 - continue - if(crayoncount == 6) - var/decalselection = input("Please select a decal") as null|anything in list("Atmospherics", "Bartender", "Barber", "Blueshield", "Brig Physician", "Captain", - "Cargo", "Chief Engineer", "Chaplain", "Chef", "Chemist", "Civilian", "Clown", "CMO", "Coroner", "Detective", "Engineering", "Genetics", "HOP", - "HOS", "Hydroponics", "Internal Affairs Agent", "Janitor", "Magistrate", "Mechanic", "Medical", "Mime", "Mining", "NT Representative", "Paramedic", "Pod Pilot", - "Prisoner", "Research Director", "Security", "Syndicate", "Therapist", "Virology", "Warden", "Xenobiology") - if(!decalselection) - return - if(user.incapacitated()) - return - if(W == user.get_active_hand() && Adjacent(usr)) - contents = W.contents - crayoncount = 0 - for(var/C in contents) - if(istype(C, /obj/item/toy/crayon)) - crayoncount += 1 - continue - if(crayoncount == 6) - decalselection = replacetext(decalselection, " ", "_") - decalselection = lowertext(decalselection) - icon_opened = ("cardboard_open_"+decalselection) - icon_closed = ("cardboard_"+decalselection) - update_icon() // a proc declared in the closets parent file used to update opened/closed sprites on normal closets - qdel(W) + if(W.contents.len < 6) + to_chat(user, "You must have a full box of crayons to perform this action") + return + var/decalselection = input("Please select a decal") as null|anything in list("Atmospherics", "Bartender", "Barber", "Blueshield", "Brig Physician", "Captain", + "Cargo", "Chief Engineer", "Chaplain", "Chef", "Chemist", "Civilian", "Clown", "CMO", "Coroner", "Detective", "Engineering", "Genetics", "HOP", + "HOS", "Hydroponics", "Internal Affairs Agent", "Janitor", "Magistrate", "Mechanic", "Medical", "Mime", "Mining", "NT Representative", "Paramedic", "Pod Pilot", + "Prisoner", "Research Director", "Security", "Syndicate", "Therapist", "Virology", "Warden", "Xenobiology") + if(!decalselection) + return + if(user.incapacitated()) + to_chat(user, "You're in no condition for the fine arts") + return + if(W != user.get_active_hand()) + to_chat(user, "You must be holding the box of crayons to perform this action.") + return + if(! Adjacent(user)) + to_chat(user, "You have moved too far away from the cardboard box.") + return + if(W.contents.len < 6) + to_chat(user, "You must have a full box of crayons to perform this action.") + return + decalselection = replacetext(decalselection, " ", "_") + decalselection = lowertext(decalselection) + icon_opened = ("cardboard_open_"+decalselection) + icon_closed = ("cardboard_"+decalselection) + update_icon() // a proc declared in the closets parent file used to update opened/closed sprites on normal closets + qdel(W)