Sorry, I do see that I wrote that question in a confusing way, but I've worked out where I was going wrong now. Thanks for taking a look.
----- Original Message ----- From: Alan Gauld <alan.ga...@btinternet.com> Date: Friday, February 6, 2009 7:22 pm Subject: Re: [Tutor] 'sphere' object is unindexable > "Mr Gerard Kelly" wrote > > >I am trying to get around the problem of sphere object being > >unindexable. > > Can you give some background? Where are you getting these spheres? > Is this a graphics program or a tookit of some kind? > > > I need to make spheres appear, positioned according to some list, > > for > > example: > > > > for i in [0,1]: > > sphere(pos=(0,i,0), radius=0.1) > > And does this work? Or do you get an error? If so what? > > > Is there any way of making these different spheres behave > > differently > > without using indexing? > > Where is the indexing issue? > Are you trying to store the spheres in a list and index the list > to access a sphere or are you trying to use an index to access > some aspect of the sphere? > > Show us the code that sdoesn't work and the error message. > Don't just describe it. Show us. Don't assume we know what > you are trying to do - we are not psychic. > > > For example, I would like to be able to make the lower sphere go red > > when it is clicked on, using this fragment of code: > > > > while True: > > if scene.mouse.events: > > m = scene.mouse.getevent() > > if m.pick is ball[0]: > > ball[0].color = color.red > > > > But obviously it won't work because I haven't named it ball[0]. > > So why don't you name it ball? and what is m.pick supposed to be? > Some attribute of a muse event based on your code but I have > no idea what it might be! > > > figure out a way to name the objects based on their position without > > using indexing. Is there any way to do this? > > A standard list should work and so provided you stored your > spheres in a list when you created them you should be able to > access them via an index. But without real code and a real > error trace we can't help very much other than by making > speculative guesses. > > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor