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.

This commit is contained in:
FlimFlamm
2017-02-08 10:08:06 -04:00
parent 47427c5aec
commit 2abbbc7a40
@@ -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)