for i in player
Posted: Mon May 12, 2008 12:50 am
OK, I am absolutely losing my mind. I can't understand what is going on here.
I am doing the following to get rid of everything in the player's inventory:
And this code only prints the name of the first object in the player, and only removes that object. The other two he happens to have are left there, so I assume the for loop closes.
If I do not have the "remove i" line in there, it prints all three objects.
... but here's the thing. I've used this same code in at least two other games. I *know* it works. It iterates through the player and removes everything the player has.
... doesn't it? I guess there is a slight chance that the game never did it for Necrotic Drift, and I never noticed, but I could have sworn that I'd see a tester try to do something weird if that was the case.
I am really, really confused. I assume that you just can't "remove i" then? Because that kills the loop? What do you guys do when you want to remove the player character of all items he might have?
I am doing the following to get rid of everything in the player's inventory:
Code: Select all
for i in player
{
print i.name
remove i
}
If I do not have the "remove i" line in there, it prints all three objects.
... but here's the thing. I've used this same code in at least two other games. I *know* it works. It iterates through the player and removes everything the player has.
... doesn't it? I guess there is a slight chance that the game never did it for Necrotic Drift, and I never noticed, but I could have sworn that I'd see a tester try to do something weird if that was the case.
I am really, really confused. I assume that you just can't "remove i" then? Because that kills the loop? What do you guys do when you want to remove the player character of all items he might have?