var/N1 = 0
for(var/obj/Items/Stick/I in usr)
if(!N1) del(I)
N1++
Is there a better way to just delete 1? Or is this correct.
ID:265574
May 4 2006, 8:01 am (Edited on May 4 2006, 8:47 am)
|
|
Ok to delete 1 of a certain item in my inventory I am currently doing something like this.
var/N1 = 0 Is there a better way to just delete 1? Or is this correct. |
In response to Papoose
|
|
Thanks, I just always like to check if there is a better way to do something or not.
|
In response to Sniper Joe
|
|
That return, isn't it unneeded? 'break', perhaps? :|
|
In response to Papoose
|
|
Papoose wrote:
Silly rabbit! > var/obj/item/I = locate() in usr I'm a bit rusty on the matter, but I do believe that should do. Make sure you check that 'I' actually exists! Also, a break in the for() loop would've worked as well. |
In response to Airjoe
|
|
Thanks, and yes I did check if they existed before that.
|
Does that even work? By the looks of it, it appears that the object type has to be the first thing in your contents, since your variable increments on the first iteration and is no longer false by the second.
|
In response to Loduwijk
|
|
No you have it wrong, I wasn't checking if it was in that place...I was before I realized there was a better way to do it. It was just checking if I had that item in my inventory and deleting only 1, hence the var/Num.
Just ignore it, I realized a better way. |
Silly rabbit!
I'm a bit rusty on the matter, but I do believe that should do.