A Building That Doesn't Show on the CityView: XML Edition!

Irkalla

ENTP POWWWEEEEEER
Joined
Sep 25, 2012
Messages
1,009
Location
Way down around Vicksburg
2gs4wvX.gif
WARNING: Very Complex and Hard to Follow XML Ahead!
2gs4wvX.gif


Spoiler :
Code:
<Buildings>
    <Row>
        [COLOR="silver"]...[/COLOR]
        <GreatWorkCount>-1</GreatWorkCount>
        [COLOR="silver"]...[/COLOR]
    </Row>
</Buildings>

This works because it defeats conditions that list the building in the CityView script (Don't check for exact equality to zero unless you have to, kids.) We get a situation where the building falls through the cracks, and is not displayed under any of the headings.
Spoiler :
Code:
for building in GameInfo.Buildings() do
	local thisBuildingClass = GameInfo.BuildingClasses[building.BuildingClass];
	if thisBuildingClass.MaxGlobalInstances <= 0 and thisBuildingClass.MaxPlayerInstances ~= 1 and thisBuildingClass.MaxTeamInstances <= 0 then
		local buildingID= building.ID;
		if pCity:GetNumSpecialistsAllowedByBuilding(buildingID) <= 0 then
			if [COLOR="Red"](pCity:IsHasBuilding(buildingID) and GameInfo.Buildings[buildingID].GreatWorkCount == 0)[/COLOR] then
				numBuildingsInThisCity = numBuildingsInThisCity + 1;
				local element = {};
				local name = Locale.ConvertTextKey( building.Description )
				element.name = name;
				element.ID = building.ID;
				sortedList[thisId] = element;
				thisId = thisId + 1;
			end
		end
	end
end
If you'd like the building to not have a listing in the Civilopedia, then set its PrereqTech to NULL, its Cost to -1, and its FaithCost to -1. Note that you may still have an article for this building, and if it's linked (usually by being a unique building, via its respective civ article) the article will still work. It simply will not be listed.

This works because it defeats the conditions of the SQL crawler's conditions in the Civilopedia script.
Spoiler :
Code:
[COLOR="Green"]-- put in all of the buildings that do not have tech requirements in the first Era for lack of a better place[/COLOR]

local sql = [[
SELECT Buildings.ID, Buildings.Description, Buildings.PortraitIndex, Buildings.IconAtlas 
FROM Buildings 
INNER JOIN BuildingClasses ON Buildings.BuildingClass = BuildingClasses.Type 
WHERE [COLOR="Red"]Buildings.PrereqTech IS NULL[/COLOR] AND [COLOR="red"](Buildings.FaithCost == 0 or Buildings.Cost >= 0)[/COLOR] AND BuildingClasses.MaxGlobalInstances < 0 AND (BuildingClasses.MaxPlayerInstances <> 1 or Buildings.SpecialistCount > 0) AND BuildingClasses.MaxTeamInstances < 0;]];
 
That's great! And very useful for those of us who use fake buildings for traits and whatnot.
 
yes, that'll be very useful in a lot of mods :goodjob:
 
yes, that'll be very useful in a lot of mods :goodjob:

Yeah, I just wanted a method to make Sumer's new UA (based on a recycled french UA) work without Lua. So I fiddled around for an hour and made it work :D
 
Sir, you are a genius.

Thank you. The ease with which mod trickery like dummy buildings can now be set as invisible makes this an asset.
 
Just a heads up for others. I followed the instructions in the op but I also set maxplayerinstance to 1 in the building class because I wanted to insure only 1 was built. Doing so messes up most of the civilopedia. I did get it work without it though so thanks for the useful information.
 
Back
Top Bottom