I am trying to load actors from a list in a csv and there starting point will be listed in the file as well I am trying to figure out how to make this work but I cannot seem to find examples of how to use a CSV to do this if anyone could either explain how this works or point me to an example (I learn better from examples) this would be terrific.
Its all right here man.
thanks I forgot to search the python site i should have figured this was a python thing not a panda thing.
ok So I got it working mostly. I can setup a read like this:
CSVload = csv.reader(open('Models/Stage.csv', "rb"))
for row in CSVload:
Column1,Column2,Column3,Column4 = row
self.clanActor = Actor.Actor("Models/"+Column2)
but then the way i want to use it cannot work as I am assigning all my models to the same tag. All I want to do is take the value of Column1 and append it to clanActor and assign the first actor based on the csv and continue through the lines. My problem is I do not know how to assign an actor to a value. Anyone know how this can be done, or how I can code this to work??
Well i ended up doing something slightly differently as per the code below:
self.goodGuy = []
self.goodGuyPosX = []
self.goodGuyPosY = []
CSVload = csv.reader(open('Models/Stage.csv', "rb"))
for row in CSVload:
Column1,Column2,Column3,Column4 = row
self.actor = Actor.Actor("Models/"+Column2)
self.goodGuy.append(self.actor)
self.goodGuyPosX.append(Column3)
self.goodGuyPosY.append(Column4)
Now I just gotta figure out how many actors it loaded so if anyone knows how to figure this out that would be great!
ok its all going good now with the code below i was able to load my characters from the list not a problem.
self.InnerSphere = []
self.InnerSpherePos = []
CSVload = csv.reader(open('Models/Stage.csv', "rb"))
for row in CSVload:
Column1,Column2,Column3,Column4 = row
if Column2 != "none":
self.actor = Actor.Actor("Models/InnerSphere/"+Column2)
self.InnerSphere.append(self.actor)
self.InnerSpherePos.append(Vec3(float(Column3),float(Column4),0))
for i in range(len(self.InnerSphere)):
self.InnerSphere[i].reparentTo(render)
self.InnerSphere[i].setScale(1.0,1.0,1.0)
self.InnerSphere[i].setPos(self.InnerSpherePos[i])
self.InnerSphere[i].setCollideMask(BitMask32.bit(2))