1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How to make Civ4 find a python package?

Discussion in 'Civ4 - Creation & Customization' started by Jean Elcard, Apr 18, 2008.

  1. Jean Elcard

    Jean Elcard The Flavournator

    Joined:
    Feb 26, 2006
    Messages:
    1,008
    Location:
    Leipzig, Germany
    Ok, here is my rather technical python problem formulated in a neutral way:

    Situation: I've written a mapscript consisting of the mymapscript.py file itself and a helperfile.py with some extra functionality.

    Objective: I would like to put the helperfile.py in its own subdirectory called mysub in the PublicMaps directory to keep the code well structured and to prevent it from showing up ingame as a seemingly valid mapscript, which it of course isn't.

    Failed Attempt: I put the helperfile.py together with a __init__.py file in the mysub directory and stated the following code in mymapscript.py in the PublicMaps folder:

    Code:
    from mysub.helperfile import Stuff
    I thought this should work (as it usually does with python outside of civ4), but it doesn't. Any ideas why?
     
  2. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    you can put the helpfile into Assets\Python. From there it should work with a additional subfolder as well.

    I would advice aganst this however - just put all into one file. A separated map script will cause trouble - most notable in Multiplayer.
     
  3. Jean Elcard

    Jean Elcard The Flavournator

    Joined:
    Feb 26, 2006
    Messages:
    1,008
    Location:
    Leipzig, Germany
    You are right, it's probably better to put everything in one file to keep it easy for the user. The only thing that's bothering me is the redundancy introduced by doing so, because I'm using this helper file in multiple mapscripts. A sub folder in Public Maps for it would still be perfect, but there seems to be no way to tell civ to search there for it.
     

Share This Page