Multi-Lightmapper script for Blender

I’m modder/developer of one old game (Oni). This game does not support lightmaps ‘on-the-fly’ (only pre-baked lightmaps are allowed). But this is not the main problem. Main problem is that Oni has limit on texture resolution (only up to 512x512). So I can’t bake the whole level to one texture. I need help from anybody: I need script for solving this problem. Script must assign multiple UVs and textures to a single object/mesh.

This script need to match these points:

  1. Script must create one UV and texture in limited resolution, but this script must not resize UV islands.

  2. When space on the first UV and texture is over, script must create new UV and new texture. New UV must be a continuation of an old UV.

  3. Also this script must assign this textures to an object automatically.

Can anybody help me with this untrivial task?

P.S. Sorry for my english.