obj/buyableClothing
var/clothingBuying
var/list/BuyableClothes = newlist(/obj/Armor/KasablancRobeMale,
/obj/Armor/KasablancRobeFemale,
/obj/Armor/KasablancPants,
/obj/Armor/KasablancCloak,
/obj/Armor/KreptkinPantsMale,
/obj/Armor/KreptkinShirtFemale,
/obj/Armor/KreptkinSkirt,
/obj/Armor/KreptkinSuitMale,
/obj/Armor/NutoriRobeFemale,
/obj/Armor/NutoriRobeMale,
/obj/Armor/PuraelicChest,
/obj/Armor/PuraelicGauntlets,
/obj/Armor/PuraelicPantsMale,
/obj/Armor/PuraelicPantsFemale,
/obj/Armor/ShaedralGoggles,
/obj/Armor/ShaedralMask,
/obj/Armor/ShaedralPants,
/obj/Armor/ShaedralShirtFemale,
/obj/Armor/ShaedralShirtMale)
DblClick()
switch(input("Are you sure you want to buy [src.name]?") in list ("Yes","Cancel"))
if("Yes")
if( (usr.capsAmount - src.price) >= 0)
var/n = ClothingList.Find(src)
usr.contents += BuyableClothes.Copy("[n]","[n]")
usr.Inventory()
usr.takeCaps(src.price)
else
alert ("You can't afford that!")
else if("Cancel")
return
var/list/ClothingList = newlist(/obj/buyableClothing/KasablancRobeMale,
/obj/buyableClothing/KasablancRobeFemale,
/obj/buyableClothing/KasablancPants,
/obj/buyableClothing/KasablancCloak,
/obj/buyableClothing/KreptkinPantsMale,
/obj/buyableClothing/KreptkinShirtFemale,
/obj/buyableClothing/KreptkinSkirt,
/obj/buyableClothing/KreptkinSuitMale,
/obj/buyableClothing/NutoriRobeFemale,
/obj/buyableClothing/NutoriRobeMale,
/obj/buyableClothing/PuraelicChest,
/obj/buyableClothing/PuraelicGauntlets,
/obj/buyableClothing/PuraelicPantsMale,
/obj/buyableClothing/PuraelicPantsFemale,
/obj/buyableClothing/ShaedralGoggles,
/obj/buyableClothing/ShaedralMask,
/obj/buyableClothing/ShaedralPants,
/obj/buyableClothing/ShaedralShirtFemale,
/obj/buyableClothing/ShaedralShirtMale)
Problem description:
Sooo for some reason this results in the ENTIRE list of items being copied over, rather than just a single item. I've tested and 'n' is outputting as the right index, everything else is working fine (it takes away the right amount for ONE item), but it just seems to be that Copy that's misbehaving...
I have the items in two separate lists because one responds to the option of double clicking to buy, whereas the other has a separate verb list.
Let's start with your specific question.
list.Find(x) returns a number.
list.Copy() takes two numeric arguments.
"[x]" is a string.
You are feeding Copy() two strings instead of numbers, causing Start and End to be invalid. Copy(), instead of failing out is just acting as though you called it without any arguments, and copying the whole list.
If you did in fact want to copy a portion of the list (which you don't, by the way, I'll get to that in a second), you'd want to be doing this instead:
Start is the position of the first item you want to copy.
End is the position immediately after the last item you want to copy.
I mentioned a couple problems, right?
So, your list is full of objects. You are attempting to make a copy of that item and give it to the user.
Problem #1) list.Copy() cannot achieve this. You are cloning a new list with references to the objects already in the list. It will appear to work just fine until someone selects the same item from the store and buys it. The last person to have bought it will suddenly lose the item, and the new player will get it. That's because you aren't actually cloning the item. You are only copying the reference to the existing object.
Problem #2) You don't want to be using a list of objects.
Problem #3) Your buyable clothes list is defined under the wrong object, and defined in such a way that you are creating one copy of every object in list/BuyableClothes for every object in list/ClothingList. This means that you are creating a whopping 361 /obj/Armor objects just by creating the 19 objects in the global ClothingList, for a grand total of 380 object instances, and 19 lists. This system should require no more than 38 object instances and one list.
I'll go over how to fix this in the next post. This is getting lengthy.