Spawning multiple units per turn.

Joined
Sep 15, 2006
Messages
511
Does anyone know how to spawn multiple units per turn in python? The initUnit function causes errors when used more than once per turn from my experiments.

In order to spawn the 10 or so units I want to I've made an algorithm that spawns a unit each turn taking up the first 10 or so turns.
 
:banana: Hell yeah :banana:

If you separate the initunit into its own little def you can run it as many times as needed. Must refresh the seed value or something :confused:.
 
Sorry for triple post but I've got some info to share in case anyone else tries to spawn multiple units per turn and gets an error in CvWBDesc .py.

In CvWBDesc there is a line of code like below
Code:
f.write("\t\tUnitAIType=%s\n" %(gc.getUnitAIInfo(unit.getUnitAIType()).getType()))

Changing it to eliminates the problem.
Code:
if (unit.getUnitAIType() != -1):
	f.write("\t\tUnitAIType=%s\n" %(gc.getUnitAIInfo(unit.getUnitAIType()).getType())
 
Does anyone know how to spawn multiple units per turn in python? The initUnit function causes errors when used more than once per turn from my experiments.

In order to spawn the 10 or so units I want to I've made an algorithm that spawns a unit each turn taking up the first 10 or so turns.

I don't understand . you can spawn any number of unit with initUnit without problems . I'm curious to see your code and what you attempt to do . ( i spawn about 500 animals with my script at the beginning of the game without any problem )

Tcho !
 
When ever I did multiple spawns I got errors in both CvWBDesc.py and CvHallOfFameScreen.py. The errors in CvWBDesc.py where experienced right after the second spawn and were not fatal. And the CvHallOfFameScreen.py error happened if I quit a game with out winning. I fixed the CvWBDesc error but haven't yet fixed the CvHallOfFameScreen error.

And about seeing the script I'll let you see mine if you let me see yours. Sounds like I might learn a thing or two.
 
When ever I did multiple spawns I got errors in both CvWBDesc.py and CvHallOfFameScreen.py. The errors in CvWBDesc.py where experienced right after the second spawn and were not fatal. And the CvHallOfFameScreen.py error happened if I quit a game with out winning. I fixed the CvWBDesc error but haven't yet fixed the CvHallOfFameScreen error.

And about seeing the script I'll let you see mine if you let me see yours. Sounds like I might learn a thing or two.

I'm curious to see the code you use with initUnit that create bugs . Just because i never had problem with it . You can see how i add animals and additionnal starting units into the scripts in the "full of resource" thread (the script is not very well structured yet so look into StoAddGameElements()) . But perhaps we don't talk about the same thing :confused:

Tcho !
 
I'll PM you my code because I don't want anyone to see it yet. I only show off finished products.
 
Back
Top Bottom