Make Buildings Invisible in Civilopedia

trystero49

Prince
Joined
Apr 30, 2012
Messages
515
I'm using Thal's code from civ up to make buildings invisible in the city view. However, this doesn't make the building invisible in the civilopedia. I did something similar to what Thal's code does to make buildings invisible in the city screen by adding a new column via SQL and then trying to exclude it from the Civilopedia in much the same way the CivilopediaScreen.lua excludes wonders. However, it doesn't work. Looking at the Lua log, I can't seem to find anything that has to do with that .lua file in the debug lug, so I'm not really sure how to approach debugging my lua code. Does anyone have any suggestions?
 
You don't need any other programming/sql data than this little addition to XML (courtesy of Putmalk, whose mod taught it me):

<GameData>
<Buildings>
<Delete Type="BUILDING_ALHAMBRA"/>
<Delete Type="BUILDING_ANGKOR_WAT"/>
<Delete Type="BUILDING_ARSENAL"/>
<Delete Type="BUILDING_BIG_BEN"/>
<Delete Type="BUILDING_BOMB_SHELTER"/>
<Delete Type="BUILDING_BRANDENBURG_GATE"/>
<Delete Type="BUILDING_BROADCAST_TOWER"/>
<Buildings>
<GameData>
 
Whoa, but that deletes the whole building, doesn't it? I want to have a building that exists, but is invisible in the civilopedia.

Anyway, I've since figured out what was wrong, but seriously, the lua.log was of no help. I can't tell what it says sometimes. It seems like it's just a bunch of stuff about map creation.
 
Whoa, but that deletes the whole building, doesn't it? I want to have a building that exists, but is invisible in the civilopedia.

Anyway, I've since figured out what was wrong, but seriously, the lua.log was of no help. I can't tell what it says sometimes. It seems like it's just a bunch of stuff about map creation.

I didn't know that you wanted a building that existed but not in the civilopedia. Glad you got it sorted out though.
 
...

Anyway, I've since figured out what was wrong, ...

Well, why don't you share the answer for others that may be looking for it as well or that may Google it in the future? Since, you already created a thread about this, asking for others to help you, nonetheless. ;)

Anyway, I was initially going to help, before I read further down the thread and saw you resolved it. I don't have access to the code or game right now, but I believe it's a simple boolean. Something like, "ShowInPedia" and you set it to "false", correct?

Well, that's what I've experienced while modding some units (one can view the barbarian units that copy regular units like the spearman, archer, or swordsman for an example) , I've never had to do it with buildings yet; it may be different.
 
ShowInPedia doesn't exist in the building schema, it exists in the unit schema. :P

As far as I'm aware, that it.

Rob (R8XFT) said:
<GameData>
<Buildings>
<Delete Type="BUILDING_ALHAMBRA"/>
<Delete Type="BUILDING_ANGKOR_WAT"/>
<Delete Type="BUILDING_ARSENAL"/>
<Delete Type="BUILDING_BIG_BEN"/>
<Delete Type="BUILDING_BOMB_SHELTER"/>
<Delete Type="BUILDING_BRANDENBURG_GATE"/>
<Delete Type="BUILDING_BROADCAST_TOWER"/>
<Buildings>
<GameData>

It's okay Rob, you don't have to credit me for XML changes. XD
 
Yeah, I'll be glad to explain how I did it. I should point out that I made it work for G&K. CivilopediaScreen.lua is slightly different for vanilla, so you'll have to do it slightly differently, even though the basic idea is the same.

First, you have to add a column to the buildings. I added the column "PediaVisible" through SQL.

Spoiler :
ALTER TABLE Buildings ADD PediaVisible Default 1;


Default is 1 because PediaVisible will be "true" for pretty much every building.

Then you make some minor adjustments to the CivilopediaScreen.lua. There are two small changes you have to make. I've included my .lua file. If you want to find the changes I made, just Ctrl-F "trystero" or "PediaVisible" and you should find them.

If you are wondering what the logic behind the changes are: basically, the lua code makes a local database from the Buildings database by looking for certain parameters. These parameters are there to ensure that Wonders and projects are excluded from the Buildings section (because those are listed in the Buildings database). I added a bit of code so that the local database the lua code creates only takes buildings that are labelled as PediaVisible. So if I want to make a building that doesn't show up in the civilopedia, I simply add "<PediaVisible>false</PediaVisible>" in its XML code. (You can do it with SQL too.

Note that I had to add that code in two different places. This is because one snippet of code deals with buildings that have tech requirements (and are put in a certain era), and the other snippet of code deals with buildings that have no tech requirements (and are put in the ancient era).

You could use this with Thal's code to make buildings that don't show up in the cityview so you have a totally invisible building that you can use to implement certain traits.
 

Attachments

Adding two different columns is inefficient though, if you are NEVER going to make builldings that are invisible in the city but not in the civilopedia (or vice versa). You don't need to add this second column if you are going to make all invisible buildings in the city invisible in the pedia as well. Just use whatever tag you are using to make them invisible in the city instead of PediaVisible.
 
Thank you for posting/uploading this code: it's just what I need for "phantom building" workarounds. (You know--invisible and indestructible freebies attached to a city, an improvement or a normal building, in order to allow changes which no other code allows yet. Phantom buildings shouldn't be listed on any screen--including Civilopedia--because they represent a game-mechanics trick, not a truly separate location.)
 
I'm having a difficult time getting this to work and perhaps I'm just missing a vital step, but whenever I load it the mod simply claims PediaVisible does not exist, though it has been implemented through SQL.
 
Back
Top Bottom