How would I make self.gold spawn 10 times in 10 different locations within the ranges of setps and setpoos?
setps = randint(-60,-25)#randomly generates X for crystal
setpoos = randint(-60,30)#randomly generates Y for crystal
self.gold = self.loader.loadModel ("models/art/cat-crystals/bvw-f2004--goldcrystal-egg/bvw-f2004--goldcrystal/goldcrystal.egg")
self.gold.setScale(.009)#scale should be .009
You just put it in a for loop and change the self.gold thing.
self.gold = 
for n in range(numgold):
x = randint(-60,-25)#randomly generates X for crystal
y = randint(-60,30)#randomly generates Y for crystal
gold = self.loader.loadModel ("models/art/cat-crystals/bvw-f2004--goldcrystal-egg/bvw-f2004--goldcrystal/goldcrystal.egg")
You then access any one gold model by its index in the self.gold list.
Are there animations that should be shared? If it’s just a static model, then the simplest means is probably to just repeatedly call “loader.loadModel”: as I recall, Panda’s model-loading is efficient enough that it shouldn’t reload from disk, but simply use the data that it already has. The call to “loader.loadModel”, the calls to random and the setting up of the gold model (scaling, reparenting and positioning it) should all presumably be performed in a loop. Finally, rather than self.gold, you might want to consider placing your gold pieces into a list if you want to keep references to them, of just using temporary variables if you don’t.
 Bah, ninja!
Each of the pieces of gold has a collision sphere so the player can collect it and a collsion ray to keep it from spawing under the map.
When I try to reference self.gold in the collisions it tells me that I can’t because its a list.
When I try to reference just gold it tells me local variable ‘gold’ referenced before assignment.
Also even when I take out the collision spheres/rays, the gold doesn’t display. I’m not sure if this is do to it not being able to or if it’s under the map but I’m guessing that its not being able to at all.
You say that you’re not seeing your gold at all: have you tried turning off any physics (especially gravity) that you have for the gold and forcing it to spawn at an easily-seen point (such as (0, 0, 0))? Have you managed to load a single gold coin, so that we can be confident that it’s not a problem with the model?
I’m afraid that I’m not quite sure of what you mean by that. You’ve said that you’re not seeing the gold appear; does this mean that you’re getting collisions with the gold, or something else?
Would you please post a little more code? In particular, I’d like to see your current spawning code and whatever it was that you were referring to when you mentioned referencing “self.gold in the collisions”, please.
I presume you followed my example? You’re getting these errors because self.gold is now a list, not a pandanode like it was before. You need to access the elements of the list to get the pandanodes out of it. If you want to do the same thing to all of them in order, you need to do something like
for gold in self.gold:
#stuff to to do the pandanode
But you really should drop what you’re doing and go and learn some basic python tutorials first. Not understanding how a for loop or a list works will make it very hard for you to code anything meaningful.
I know how loops and lists work I just haven’t done it in a while. But thank you for the suggestion