zlib python module?

OverloadUT

Stats Monkey
Joined
Nov 9, 2005
Messages
352
Location
Novato, CA
Is the zlib python module available in Civ4? I need to compress some strings and I'm trying to figure out what the best method of doing it would be.

If zlib isn't available, what should I use? I found a huffman class created in Python, so I'll use that if I can't figure anything out that would be faster.
 
If you looking to pickle some data then do a search on the forums for sdToolKit by Stone-D, or look in just about any major mod and you can find a copy of it.

Beyond that I believe just about any module you can call in normal python can be called in civ python.
 
OverloadUT said:
Is the zlib python module available in Civ4? I need to compress some strings and I'm trying to figure out what the best method of doing it would be.

If zlib isn't available, what should I use? I found a huffman class created in Python, so I'll use that if I can't figure anything out that would be faster.

I believe that any module found in the standard python package (at least, with the version that the game shipped with) can be used. Even if you don't have the module you want, however, you can always put the module you do want to use into the python directory of your mod and load it anyway. So, in theory, you can use any python module you find on the far reaches of the internet. It just so happens that the zlib module is already included so you won't need to rally up the files for your mod's python directory.
 
Gerikes said:
It just so happens that the zlib module is already included so you won't need to rally up the files for your mod's python directory.

Hmm, then the problem is that I don't know how to use it! :lol:

Following some examples I found on the web, I tried putting "import zlib" but I get a "No module named zlib" error. I also tried just using "compress()" and of course it says the function is not defined.

Any idea what I'm doing wrong? Thanks in advance for helping this Python noob out.
 
OverloadUT said:
Hmm, then the problem is that I don't know how to use it! :lol:

Following some examples I found on the web, I tried putting "import zlib" but I get a "No module named zlib" error. I also tried just using "compress()" and of course it says the function is not defined.

Thanks in advance for helping this Python noob out.

No, you're right, I was mistaken. I just tried it under the python console in Civ4 and got that same error. Apparently it doesn't load with the game.

I was curious, so I messed around until I got it working. Assuming you have an actual version of python installed on your computer, go to the C:\Python24\DLLs directory, and copy the "zlib.pyd" file to "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Assets\Python\System".

This has the obvious problem that you need to put it into the main Firaxis folder to get it to work, but I tried quickly doing this with a mod and didn't get it to work. Perhaps you'd have more luck though?
 
Just wanted to follow up:

I was able to get zlib to work perfectly by placing it in the Assets/Python/System directory in the installation folder. I tried to get it to work by putting it in CustomAssets/System and even in the same directory as my scripts but it did not work, so it seems that the only way for it to work is out of the installation directory, as your findings indicated.

However, my mod will need to reside in the main Assets folder anyway (not in a mod or CustomAssets) so it's not that big of a deal of me.

Thanks for your help!
 
OverloadUT said:
Just wanted to follow up:

I was able to get zlib to work perfectly by placing it in the Assets/Python/System directory in the installation folder. I tried to get it to work by putting it in CustomAssets/System and even in the same directory as my scripts but it did not work, so it seems that the only way for it to work is out of the installation directory, as your findings indicated.

However, my mod will need to reside in the main Assets folder anyway (not in a mod or CustomAssets) so it's not that big of a deal of me.

Thanks for your help!

Wait, by "reside in the main assets folder" do you mean in the Main mod folder "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Mods", or actually inside the main assets folder "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Assets". If you overwrite any files there you'll have some pretty angry people who downloaded your mod and now all their other mods and default Civ as well are broken.
 
I am aware :)

My "mod" runs serverside on Pitboss servers - there will be two methods of installing it - one is in a Mod folder, and the other is to reside right in your Assets file (overwriting one of the originals) - the second method is the equivilant of using the CustomAssets method that most mods let you do, but that won't work in multiplayer, so the actual Assets directory must be used.

My readme will have a list of pros and cons for each method, and will make sure people realize the "risks" of having a "mod" installed in the base Assets directory. The main advantage of not doing it like a mod is that each player will not need to get the mod and keep it up to date with the server's version. Since the mod only runs serverside anyway, it makes sense to only have the files serverside. Of course, the server will have to have "Lock Modified Assets" unchecked and players will have to deal with the "Your game files differ from server" warning when they log in. But it'll be worth it to get the features this mod will provide. ;)
 
OverloadUT said:
I am aware :)

My "mod" runs serverside on Pitboss servers - there will be two methods of installing it - one is in a Mod folder, and the other is to reside right in your Assets file (overwriting one of the originals) - the second method is the equivilant of using the CustomAssets method that most mods let you do, but that won't work in multiplayer, so the actual Assets directory must be used.

My readme will have a list of pros and cons for each method, and will make sure people realize the "risks" of having a "mod" installed in the base Assets directory. The main advantage of not doing it like a mod is that each player will not need to get the mod and keep it up to date with the server's version. Since the mod only runs serverside anyway, it makes sense to only have the files serverside. Of course, the server will have to have "Lock Modified Assets" unchecked and players will have to deal with the "Your game files differ from server" warning when they log in. But it'll be worth it to get the features this mod will provide. ;)

I guess I'm just confused as to why you are not able to use a mod directory to do this rather than overwrite either the main assets or the custom assets.
 
Well as I said, you will also be able to install my mod as an actual "mod" if you want to - the disadvantages are that you have to get all of your players to download and properly install the mod as well, and all of your players have to active the mod before connecting to the game, which ispretty inconvenient. As a host, I understand the importance of making everything very easy for the players, even if it means more work for the host.

For game hosts that want to be able to use the "Lock Modified Assets" option (for tournament games or games with people they don't trust) they can use the mod method, but my guess is that a lot of hosts will want to use the file replacement method.

A lot of Pitboss hosts run their pitboss servers on a dedicated machine that never actually plays Civ4, so having modified files isn't that bad.
 
Back
Top Bottom