ID:272705
 
I'm making a TCG and am now working on the battle system, in this system when a card is played it its added to a list and a new proc creates a copy of that object at a certain number of space from the user (depending on the card), the problem I'm having is that I can't seem to figure out how to delete the new object at that spacific location when the card is discarded with out deleting other instances of that object.
It's very difficult to understand what you're saying. Perhaps some code depicting your efforts would help?

What I think you're doing is not checking the type.
You have to use istype() to check for the type of card. If your cards are all the same object, like obj/card, then you will need a type of unique identifier. Of course, if this last form is the case, I would suggest you overhaul it so that it resembles the first.

The other possibility is that after you're deleting the first object type in your loop, you aren't breaking out of the loop.

Some examples:
var/list/Cards
for(var/obj/card/King/K in locate(1,2,1)) //I can't remember if locate returns a list or not, this is just off the top of my head.
if(istype(K,/obj/card/King))
del K
break //so we don't delete other Kings


for(var/obj/card/C in locate(1,2,1))
if(C.ISCARD==TRUE)
del C
break


Of course, something else could be going on here that I haven't been able to glean from your post.
In response to Rockinawsome
Sorry, I can be slightly bad at discriptions. Basicly what I want to do is turn this in to code: "Delete all cards at position(x,y,z) from user" but I cant figure out how to do this.
In response to Nightmare Fantasy
Assuming all the cards are under a standard typepath (say, /obj/cards):
proc/delete_cards(atom/a)
for(var/obj/cards/c in a.contents)
del a

return 1 //Deleted successfully.
In response to Popisfizzy
Thank you for the help :)
In response to Popisfizzy
Popisfizzy wrote:
proc/delete_cards(atom/a)
for(var/obj/cards/c in a.contents)
del a // I assume you meant del c instead?

return 1 //Deleted successfully.
In response to Schnitzelnagler
Aye.