Specialist slots

That will drop the buildings from the pedia, but they'll still show up in the list in the city screen.

You could easily apply the same filter logic in CvMainInterface.py where it draws the build buttons.

. . . it drops them from the list after building it, by hardcoded index.

Yes, if you have a lot of buildings to remove this is better as it will look them up once when the mod loads. You can employ BUG to help here.

1. Create a new Python module, say "GraphicalOnlyBuildings.py" (bad name, pick your own).

2. In it create a function called "init" that builds a list of the buildings to be removed. This list can be a simple global variable.

Code:
# GraphicalOnlyBuildings.py

from CvPythonExtensions import *
import BugUtil

buildings = []
def addBuilding(szType):
    eBuilding = gc.getInfoTypeForString(szType)
    if eBuilding != -1:
        buildings.append(eBuilding)
    else:
        BugUtil.error("Failed to locate building %s", szType)

def isGraphicalOnly(eBuilding):
    return eBuilding in buildings

def init():
    addBuilding("BUILDING_ADD_SCIENTIST_SLOT")
    addBuilding("BUILDING_ADD_MERCHANT_SLOT")

3. Add a line to Config/init.xml to initialize the new module.

Code:
<init module="GraphicalOnlyBuildings"/>

4. Call GraphicalOnlyBuildings.isGraphicalOnly() from SevoPediaBuilding and CvMainInterface.

Code:
import GraphicalOnlyBuildings

...


def getBuildingType(self, iBuilding):
	if (isWorldWonderClass(gc.getBuildingInfo(iBuilding).getBuildingClassType())):
		return 2
	elif (isNationalWonderClass(gc.getBuildingInfo(iBuilding).getBuildingClassType())):
		return 1
	elif (GraphicalOnlyBuildings.isGraphicalOnly(iBuilding)):
		return 3
	else:
		return 0

Oh, and the Mac ignoring schema/DLL? Pretty well known by everyone who's seriously tried modding that version.

Sure, the Mac does not have a DLL, but that doesn't mean it ignores the Schema. I just want to know if people assume this because the Mac has no DLL, there are no schema files in the Mac version, or they've modified the schema files with no effect.
 
Maybe I'm doing something wrong but I can't get either method you posted to work. This is what I had for the first method:

Code:
	def getBuildingType(self, iBuilding):
		if (isWorldWonderClass(gc.getBuildingInfo(iBuilding).getBuildingClassType())):
			return 2
		elif (isNationalWonderClass(gc.getBuildingInfo(iBuilding).getBuildingClassType())):
			return 1
		elif (iBuilding in (gc.getInfoTypeForString("BUILDING_TRAIT_SPIRITUAL"))):
			return 3
		else:
			return 0

What happens here is that I can load the pedia but nothing happens when clicking on the Buildings entry in the list. It won't display the list of buildings at all. Same thing with National and World Wonders, all other entries are fine.

The second method loads the pedia without issue but the building I wish to hide is still there. When I launch an actual game I get a message about GraphicalOnlyBuildings not being initialized or something. I haven't renamed anything but I wasn't sure where I should put the GraphicalOnlyBuildings.py. I tried in Python/ and in Python/BUG/ but there was no difference.

Additionally I couldn't find anything resembling the code above in CvMainInterface.py so I left that alone entirely. What should I be looking for in that file?

Apologies for my inexperience.

Sure, the Mac does not have a DLL, but that doesn't mean it ignores the Schema. I just want to know if people assume this because the Mac has no DLL, there are no schema files in the Mac version, or they've modified the schema files with no effect.

The schema files are included with Mac BTS but they are definitely ignored. I've tried adding entries and even ASCII grafitti to them and nothing happens or changes. I deleted them all from my mod, which uses modular loading, and it caused no issues. Of course then I learned I need to put them all back to make it Windows compatible ><
 
I think I've found where the list of buildings in the city screen is created. In updateCityScreen(), look for the deeply indented block starting with "for i in range(gc.getNumBuildingInfos)". I'd replace that by creating a list of visible buildings and wonders somewhere, and then looping over that list instead of all indices.
 
There is a bug in what you have. My example wasn't clear because I had two buildings listed. In Python if you have a single value inside parentheses (x) it will not be turned into a list. Then the "in" operator won't work for it. To fix it, just add a comma (red):

Code:
elif (iBuilding in (gc.getInfoTypeForString("BUILDING_TRAIT_SPIRITUAL")[B][COLOR="Red"],[/COLOR][/B])):

Regarding the other method, without the logs it's hard to tell. Take a look at the Troubleshooting page for information on how to set up logging and post the log files here. You can put the .py file anywhere under Python. You can even create your own folder under Python for your stuff, or just stick it in Contrib or wherever.

Make sure in the <init ...> element you don't have the ".py" extension and that the name matches the filename (other than the .py) exactly.

The schema files are included with Mac BTS but they are definitely ignored. I've tried adding entries and even ASCII grafitti to them and nothing happens or changes.

Okay, that convinces me that the schema files are ignored, but that still doesn't mean you cannot add elements to the XML files. But you tried adding it everywhere in the file, right? Even before the <type> element? bGraphicalOnly is the first element read in the SDK. Who knows how Aspyr (the Mac porting company) wrote their parser. :(
 
Those sneaky commas! It works now. At the moment I'm not planning many 'fake' buildings so I'll stick with the first method now. I have bookmarked this thread for when I want to try tackle the other method again. Thanks so much.

I think I've found where the list of buildings in the city screen is created. In updateCityScreen(), look for the deeply indented block starting with "for i in range(gc.getNumBuildingInfos)". I'd replace that by creating a list of visible buildings and wonders somewhere, and then looping over that list instead of all indices
.

I had a look through that section and, assuming I'm interpreting it correctly, it looks like that part is also where it extracts yield/commerce/health/happiness/etc information from the buildings in the city. So if I stuff it up it won't display those right either. For the time being I'll leave it alone, the fake buildings don't intrude as much there as they did in the Civilopedia, I'll just give them blank names.
 
It extracts that information so it can go into the building list display; this is how you see the smiley face for a temple or the like. I don't believe that has any effect other than that display. I'm not suggesting that you change the contents of the loop, only that you change the loop condition to skip certain buildings entirely.
 
Top Bottom