AddList / removeList

BlitzMax Forums/BlitzMax Beginners Area/AddList / removeList

Ant(Posted 2006) [#1]
Hi. I have an object of type TBall (called PlayerBall) and a list of TBalls (called ballList). What I'd like to do is swap playerBall with the first in the list of ballList. (so playerBall becomes first in the list of BallList and the first object in BallList now becomes PlayerBall).

To copy the first in the list of BallList I have done this:



I'm getting some strange results and I'm assuming its down to what I'm doing here?
thanks


Diablo(Posted 2006) [#2]
i didnt think you could do that...
playerBall=TBall(ballList.removefirst())
i dont think it returns an object

...

what you will need todo is
playerball = tball(balllist.first())
balllist.removefirst()

...

of course i coould be wrong and you could just do a null test on playerball


Ant(Posted 2006) [#3]
But isnt that just adding playerBall to the first position in the list and then instantly removing it? (as its in first position after adding it)?
EDIT
Crap, of course its not - but its just copying the first in the list to playerBall and then removing it(without adding playerBall to ballList). I guess this would be the solution:




Diablo(Posted 2006) [#4]
but it works :D


edit: oh, ok np


Ant(Posted 2006) [#5]
thanks for the help!