Space Colonization modmod

We need a building that will make contact with all civilizations in the modern era+ (for all civilizations, not WW; NW maybe). On my map "two planets" it's very important
 
TPEHEP: I will look into it and see if I can do that. Is there another wonder that I could use as a template?
 
TPEHEP: I will look into it and see if I can do that. Is there another wonder that I could use as a template?

The same time, these functions were at the Ishtar Gate in C2C.

A little thought, I believe that this should even be a miracle, but a technology. Something after the satellites.
 
It looks like the special function of the Ishtar Gate is done through Python code. I haven't yet tried to put any custom python into buildings, and I'm not sure if I can without editing some of the core files. I'll experiment with that, though it could be tricky.
 
It looks like the special function of the Ishtar Gate is done through Python code. I haven't yet tried to put any custom python into buildings, and I'm not sure if I can without editing some of the core files. I'll experiment with that, though it could be tricky.
You should not need to edit any core files with the BUG Modular Python we use. Let me know if I can help.
 
Thanks DH. I've been looking at some of the existing files and trying to figure it out. I will ask you if I need help.
 
Roughly speaking there are four files needed when doing python for a building.
  1. Config\Init.XML This file tells BUG what configuration files should be used when putting the modular python together

  2. Config\(name).XML This is the file that tells BUG what the name of the python files are and what events it calls. Events are those normally defined in the EventManager.py which in non BUG systems contains all the python code in one file.

  3. Python\(modder\module name)\(module name)_EM.py This contains the main python control code. The name is the standard I use but others may use a different naming structure and sometimes we have many of these in one folder so as to show who provided the original code.

  4. Python\(modder\module name)\(module name).py Completely optional as the code can be put in the _EM file. I usually have it in this separate file because I can have it contain the code from the original here making it easier to keep it up to date if the source modder is actively improving the mod.
The above makes it easy to include stuff by Platyping, The_J and others. Orion Veteran uses the other BUG way of doing things
 
Thanks a lot, DH. I am working on a Digital Embassy national wonder that I hope will fulfill TPEHEP's request, but for now I am trying to see if I can get python to work at all.

I added the following line to Assets\Config\init.xml:
Code:
<load mod="Pepper2000Buildings"/>

Also in Assets\Config, I added the following file, Pepper2000Buildings.xml:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
    Pepper2000's wonders: python code
-->
<mod id="Pepper2000Buildings" module="Pepper2000Buildings">
      <event type="buildingBuilt" function="onBuildingBuilt"/>
    <init/>
</mod>

Finally, I created the folder Assets\Python\Pepper2000 and added the file Pepper2000Buildings.py with the following content:
Code:
## Buildings for the Space Colonization projects
##  by Pepper2000


from CvPythonExtensions import *
import CvUtil
# import CvScreensInterface
import CvDebugTools
# import CvWBPopups
# import PyHelpers
# import Popup as PyPopup
# import CvCameraControls
# import CvTopCivs
# import sys
# import CvWorldBuilderScreen
# import CvAdvisorUtils
# import CvTechChooser

gc = CyGlobalContext()

# globals
###################################################

def onBuildingBuilt(argsList):
    'Building Completed'
    pCity, iBuildingType = argsList
    game = gc.getGame()

    iPlayer = pCity.getOwner()
    pPlayer = gc.getPlayer(iPlayer)
    pPlayer.setGold(12345)

That's not the actual intended effect, of course. I wrote some code that I expect to set the player's gold to 12345 upon completion of any building, so it should be easy to see if it's working. But there's no effect. What am I missing?
 
You do need to "import sys" I think.

Are you getting any Python errors either to screen or in any of the Python Logs? Do you have the logs on plus Python Exceptions on.

edit Also you should do a check for invalid/null pCity and posibely non negative IBuildingType, but they would cause errors.
 
No errors coming up. It appears that the python code is not loading at all. I tried inserting some clear bugs and they weren't picked up. Could it be that BUG is failing to find the Pepper2000Buildings.py file? Is there some file naming/placement convention that I might be violating?
 
If it was loading you would get an error because you have the <init/> in the config XML but no def init: in the code. This suggests the problem is the init.xml. Post it and I will have a look.
 
Here's the init.xml as it is now.
Spoiler :
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- ReModified by StrategyOnly -->
    <!--
    Main BUG Mod Initialization

    This file initializes the BUG Core and all mods.

    Copyright (c) 2008 The BUG Mod.
    -->
<bug>
    <!-- BUG Core -->
    <load mod="BUG Config"/>
    <load mod="BUG Core"/>
    <!-- Civilization Core -->
    <!-- Domestic and Military Advisors and Civilopedia are chosen by options -->
    <init module="CvScreensInterface"/>
    <!-- Utility Modules -->
    <init module="FontUtil" immediate="True"/>
    <symbol id="war" from="COMMERCE_GOLD" offset="25"/>
    <symbol id="peace"/>
    <symbol id="space"/>
    <!-- blank symbol the same size as other standard symbols -->
    <symbol id="militaryinstructor" name="MILITARY_INSTRUCTOR"/>
    <symbol id="land" name="DOMAIN_LAND"/>
    <symbol id="sea" name="DOMAIN_SEA"/>
    <symbol id="air" name="DOMAIN_AIR"/>
    <symbol id="sentry" name="ORDER_SENTRY"/>
    <symbol id="fortify" name="ORDER_FORTIFY"/>
    <symbol id="establish" name="ORDER_ESTABLISH"/>
    <symbol id="escape" name="ORDER_ESCAPE"/>
    <symbol id="wait" name="ORDER_WAIT"/>
    <symbol id="upgrade"/>
    <symbol id="cancel"/>
    <symbol id="ss casing" from="HAPPY" offset="-25"/>
    <symbol id="ss cockpit"/>
    <symbol id="ss docking bay"/>
    <symbol id="ss engine"/>
    <symbol id="ss life support"/>
    <symbol id="ss stasis chamber"/>
    <symbol id="ss thruster"/>
    <symbol id="citizen" from="POWER" offset="1"/>
    <symbol id="greatgeneral" name="GREAT_GENERAL"/>
    <init module="AttitudeUtil">
        <!-- Furious, Annoyed, Cautious, Pleased, Friendly -->
        <arg name="colors" type="tuple">"COLOR_RED",
            "COLOR_CYAN",
            "COLOR_CLEAR",
            "COLOR_GREEN",
            "COLOR_YELLOW"</arg>
        <!-- Non-memory attitude modifier keys -->
        <arg name="modifiers" type="tuple">"TXT_KEY_MISC_ATTITUDE_LAND_TARGET",
            "TXT_KEY_MISC_ATTITUDE_WAR",
          

"TXT_KEY_MISC_ATTITUDE_PEACE",
            "TXT_KEY_MISC_ATTITUDE_SAME_RELIGION",
            "TXT_KEY_MISC_ATTITUDE_DIFFERENT_RELIGION",
          

"TXT_KEY_MISC_ATTITUDE_BONUS_TRADE",
            "TXT_KEY_MISC_ATTITUDE_OPEN_BORDERS",
            "TXT_KEY_MISC_ATTITUDE_DEFENSIVE_PACT",
          

"TXT_KEY_MISC_ATTITUDE_RIVAL_DEFENSIVE_PACT",
            "TXT_KEY_MISC_ATTITUDE_RIVAL_VASSAL",
            "TXT_KEY_MISC_ATTITUDE_SHARE_WAR",
          

"TXT_KEY_MISC_ATTITUDE_FAVORITE_CIVIC",
            "TXT_KEY_MISC_ATTITUDE_TRADE",
            "TXT_KEY_MISC_ATTITUDE_RIVAL_TRADE",
          

"TXT_KEY_MISC_ATTITUDE_FREEDOM",
            "TXT_KEY_MISC_ATTITUDE_EXTRA_GOOD",
            "TXT_KEY_MISC_ATTITUDE_EXTRA_BAD"</arg>
    </init>
    <event type="LanguageChanged" module="AttitudeUtil" function="initModifiers"/>
    <symbol id="furious" name="ATTITUDE_FURIOUS" from="POWER" offset="4"/>
    <symbol id="annoyed" name="ATTITUDE_ANNOYED"/>
    <symbol id="cautious" name="ATTITUDE_CAUTIOUS"/>
    <symbol id="pleased" name="ATTITUDE_PLEASED"/>
    <symbol id="friendly" name="ATTITUDE_FRIENDLY"/>
    <init module="ColorUtil">
        <!--
            You can safely modify this list to change the color dropdown menus
            for color options. You can change the text displayed in the menus by
            adding translations for your new colors to Colors_CIV4GameText.xml
            in the XML/Text directory.
        -->
        <arg name="colors" type="tuple">"COLOR_RED",
            "COLOR_YELLOW",
            "COLOR_CYAN",
            "COLOR_GREEN",
            "COLOR_BLUE",
            "COLOR_MAGENTA",
            "COLOR_WHITE",
            "COLOR_LIGHT_GREY",
            "COLOR_GREY",
            "COLOR_DARK_GREY",
            "COLOR_BLACK"</arg>
    </init>
    <event type="LanguageChanged" module="ColorUtil" function="createColors"/>
    <events module="DealUtil" function="addEvents"/>
    <events module="DiplomacyUtil" function="addEvents"/>
    <extend how="after" module="DiplomacyUtil" function="handleAIComment" to="CvDiplomacyInterface" as="beginDiplomacy"/>
    <extend how="after" module="DiplomacyUtil" function="handleUserResponse" to="CvDiplomacyInterface" as="handleUserResponse"/>
    <!-- Rise of Mankind -->
    <events module="WarPrizes"/>
    <events module="ScreenResolutionSize"/>
    <events module="CvWaterAnimalsModEventManager"/>
    <events module="NukeAfterEffects"/>
    <events module="CvEnhancedTechConquestEventManager"/>
    <!-- Rise of Mankind end -->
    <init module="GGUtil"/>
    <init module="GPUtil"/>
    <init module="ReligionUtil"/>
    <init module="TechUtil"/>
    <init module="TradeUtil"/>
    <init module="TraitUtil"/>
    <init module="UnitUtil"/>
    <gameutils module="WidgetUtil" handler="getWidgetHelp"/>
<!--  Removed while I try and get Platy Tech Screen working
    <event type="OnLoad" module="CvTechChooser" function="resetTechPrefs"/>
    <event type="GameStart" module="CvTechChooser" function="resetTechPrefs"/>
-->
    <!-- Mods -->
    <!--
<load mod="BUG Main Interface"/>
    -->
    <!--BUG Main Interface is already initialized in CvViewport::resizeForMap-->
    <load mod="BUG City Screen"/>
    <load mod="BUG Advisors"/>
    <load mod="Customizable Domestic Advisor"/>
    <load mod="Better Espionage"/>
    <load mod="All Eras Dawn of Man Screen"/>
    <load mod="TechWindow"/>
    <load mod="Not Just Another Game Clock"/>
    <load mod="Advanced Scoreboard"/>
    <load mod="Plot List Enhancements"/>
    <load mod="Autolog"/>
    <load mod="Reminder"/>
    <!-- requires Autolog -->
    <load mod="Civ4lerts"/>
    <load mod="MoreCiv4lerts"/>
    <load mod="Unit Naming"/>
    <load mod="FavoriteCivicDetector"/>
    <load mod="EventSigns"/>
    <load mod="Strategy Overlay"/>
    <load mod="StatusDump"/>
    <load mod="MovieMod"/>
    <!--RevolutionDCM start - mod components -->
    <load mod="RevDCM"/>
    <load mod="Revolution"/>
    <!--RevolutionDCM end-->
    <load mod="Abandon City Mod"/>
    <!-- BULL -->
    <load mod="BULL Core"/>
    <load mod="BULL Actions"/>
    <load mod="BULL City Bar"/>
    <load mod="BULL Misc Hovers"/>
    <load mod="AutoSave"/>
    <load mod="MapFinder"/>
    <load mod="Advanced Combat Odds"/>
    <!-- BUFFY -->
    <load mod="BUFFY"/>
    <load mod="RoMSettings"/>
    <load mod="DiplomacySettings"/>
    <load mod="AutomatedSettings"/>
    <!--
<load mod="EnhancedTechConquest"/>
    -->
    <!--Mad Nukes Mod-->
    <events module="MADNukesEventManager"/>
    <!--Mad Nukes Mod-->
    <!-- Options Screen -->
    <screen id="BUGFull">
        <tab module="BugGeneralOptionsTab"/>
        <tab module="RevDCMOptionsTab"/>
        <tab module="RoMOptionsTab"/>
        <tab module="ANDDiplomacyTab"/>
        <tab module="ANDAutomationsTab"/>
        <tab module="BugMapOptionsTab"/>
        <tab module="BugCityScreenOptionsTab"/>
        <tab module="BugAdvisorOptionsTab"/>
        <tab module="BugAlertsOptionsTab"/>
        <tab module="BugScoreOptionsTab"/>
        <tab module="BugNJAGCOptionsTab"/>
        <tab module="BugPleOptionsTab"/>
        <tab module="BugACOOptionsTab"/>
        <tab module="BugUnitNameOptionsTab"/>
        <tab module="BugAutologOptionsTab"/>
        <tab module="BugSystemOptionsTab"/>
        <tab module="BugCreditsOptionsTab"/>
    </screen>
    <load mod="Female Missionaries"/>
    <load mod="Caveman2Cosmos"/>
    <load mod="MusicUpdate"/>
    <load mod="CaptureSlaves"/>
    <load mod="AnimalPlacing"/>
    <load mod="Ishtar"/>
    <load mod="Temple_of_the_Great_Jaguar"/>
    <load mod="Great Bath"/>
    <load mod="MasterModList"/>
    <load mod="ProcessUpgrades"/>
    <load mod="The_JMods"/>
    <load mod="Topkapi_Palace"/>
    <load mod="Partisan"/>
    <load mod="Heroes"/>
    <load mod="InitMilitaryPromos"/>
    <load mod="Modifieda4"/>
    <load mod="FieldGold"/>
    <load mod="AppianWay"/>
    <load mod="GoldenSpike"/>
    <load mod="Alamo"/>
    <load mod="MarcoPolo"/>
    <load mod="MaginotLine"/>
    <load mod="MachuPicchu"/>
    <load mod="Route66"/>
    <load mod="GreatZimbabwe"/>
    <load mod="SilkRoad"/>
    <load mod="KentuckyDerby"/>
    <load mod="Helsinki"/>
    <load mod="Reichstag"/>
    <load mod="TheMotherlandCalls"/>
    <load mod="PlatyPingWonders"/>
    <!--
 <load mod="AgingAnimals"/>
    -->
    <load mod="BeastMaster"/>
    <!--
 <load mod="BarbarianDiplomacy"/>
    -->
    <load mod="BuildListScreen"/>
    <load mod="LascauxCaves"/>
    <load mod="StarSigns"/>
    <load mod="NaturalWonders"/>
    <load mod="GreatPersonBornDisplay"/>
    <load mod="Pepper2000Buildings"/>
    <load mod="Cleopatra_Needle"/>
    <!--load mod="WorldTech"/-->
    <events module="ToolsEventManager"/>
</bug>

The only change is the line <load mod="Pepper2000Buildings"/> near the end.
 
interesting, so far I have managed to show that it is actually loading the module, now to see if it is calling the buildingBuilt stuff correctly. It mat be that one of the other modules is using that event and instead of doing the same as continue through the code it is exiting the code saying it is all done.
 
Thanks DH. Any more insight into the issue? My understanding is that all modules that want to execute code upon the completion of a building use the buildingBuilt event, and so when a building is built, the buildingBuilt event triggers and calls every function tied to it. The functions then should match whatever I call it in the python module, but seems typically to be called onBuildingBuilt. Is that correct?

Also, does the file structure in the Python directory matter?
 
No sorry distracted with RL.

Yes but if one of them has return 1 then it will stop any others being run. So we need to look at all the modules that have the buildingEvent and check they are not doing that.
 
OK, thanks. I looked through the other modules and didn't find any return statements in an onBuildingBuilt function, but it is possible that I missed it.

If all else fails, I think I could put my code in another module that is loading properly.
 
I put trace (BUG) prints in and it was initialising fine, I added an init function but it was not doing the onBuildingBuilt function at all.
 
How are you coming along with the python code? :)

And will the next version of your modmod be compatible with this one? I.E. if I'd make a map using all your terrrains, will it still be playable in the next version?
 
Back
Top Bottom