Issues with Buildings with Great Work slots, and a way of solving them.

Leugi

Supreme Libertador
Joined
Jan 25, 2013
Messages
1,675
Location
Bolivia
A new, better and dynamic version of Culture Overview was released, plese use that one instead.


Well... There's a big issue with BNW's Great Work system, that is a harsh thing for modding:

The Culture Overview Screen

There, in the "Your Culture" tab, you can swap Great Works from one building to another, getting theme bonuses and all. The problem is, that the way each building is showed is Hardcoded! I thought that the left side would show it, but that one is coded so it only shows Wonders, the Hermitage and the Oxford University.

This means, if you add Great Work slots to a custom building that isn't a wonder or an override of a building that already has a Great Work (national wonders don't count, as they are hard coded one by one), the new buiilding Great Work Slots will not show in that tab. So, custom Buildings with slots can't swap GW to other buildings, being a terrible problem for theming and inmersion itself.

This is because of "CultureOverview.lua"... That's the lua file where it defines the necessary variables for each tab, and where the conditions for the left side are defined. Good news is, that the left tab condition can be easily changed so it allows buildings other than Wonders and those two National Wonders.

So, I made a little CultureOverview.lua replacement. What this does is enabling building other than wonders and the top buildings (museum, broadcast tower, etc) to show in the left side if they have Great Work slots. You don't need to change anything of the lua file to add the buildings, simply add GW slots and they will be able of showing up on that tab after building them.

CultureOverview.lua Replacement file for Custom Buildings with GW slots to work. (or check the attachment)

However, this presents us a problem. In order to use this you must upload it to your mod with the same name, and with VFS=True... So, this will generate compatibility issues with mods that modify CultureOverview.lua but without the necessary change for extra GW slot buildings.

So... before that happens, I ask anyone that has to change that to include this specific change from the Original CultureOverview to whatever you Use:

Original Code (from Line 563 to 655)
Spoiler :

Code:
    local buildings = {
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_AMPHITHEATER",
			BuildingSortColumn = "AmphitheaterSort",
			IconControlNames = {"AmphitheaterGreatWork"},
			HighlightIconControlNames = {"AmphitheaterGreatWorkHL"},
			GhostIconControlNames = {"AmphitheaterGreatWorkGhost"},
			ColumnImageControl = Controls.AmphitheaterImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_OPERA_HOUSE",
			BuildingSortColumn = "OperaHouseSort",
			IconControlNames = {"OperaHouseGreatWork"},
			HighlightIconControlNames = {"OperaHouseGreatWorkHL"},
			GhostIconControlNames = {"OperaHouseGreatWorkGhost"},
			ColumnImageControl = Controls.OperaHouseImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_MUSEUM",
			BuildingSortColumn = "MuseumSort",
			IconControlNames = {"MuseumGreatWork1", "MuseumGreatWork2"},
			HighlightIconControlNames = {"MuseumGreatWork1HL", "MuseumGreatWork2HL"},
			GhostIconControlNames = {"MuseumGreatWork1Ghost", "MuseumGreatWork2Ghost"},
			ThemeBonusControlName = "MuseumThemeBonus";
			ColumnImageControl = Controls.MuseumImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_BROADCAST_TOWER",
			BuildingSortColumn = "BroadcastTowerSort",
			IconControlNames = {"BroadcastTowerGreatWork"},
			HighlightIconControlNames = {"BroadcastTowerGreatWorkHL"},
			GhostIconControlNames = {"BroadcastTowerGreatWorkGhost"},
			ColumnImageControl = Controls.BroadcastTowerImage,
		},	
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_CATHEDRAL",
			BuildingSortColumn = "CathedralSort",
			IconControlNames = {"CathedralGreatWork"},
			HighlightIconControlNames = {"CathedralGreatWorkHL"},
			GhostIconControlNames = {"CathedralGreatWorkGhost"},
			ColumnImageControl = Controls.CathedralImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_PALACE",
			BuildingSortColumn = "PalaceSort",
			IconControlNames = {"PalaceGreatWork"},
			HighlightIconControlNames = {"PalaceGreatWorkHL"},
			GhostIconControlNames = {"PalaceGreatWorkGhost"},
			ColumnImageControl = Controls.PalaceImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_NATIONAL_EPIC",
			BuildingSortColumn = "NationalEpicSort",
			IconControlNames = {"NationalEpicGreatWork"},
			HighlightIconControlNames = {"NationalEpicGreatWorkHL"},
			GhostIconControlNames = {"NationalEpicGreatWorkGhost"},
			ColumnImageControl = Controls.NationalEpicImage,
		},		
		BuildingEntry{
			BuildingClass = "BUILDINGCLASS_HEROIC_EPIC",
			BuildingSortColumn = "HeroicEpicSort",
			IconControlNames = {"HeroicEpicGreatWork"},
			HighlightIconControlNames = {"HeroicEpicGreatWorkHL"},
			GhostIconControlNames = {"HeroicEpicGreatWorkGhost"},
			ColumnImageControl = Controls.HeroicEpicImage,
		},		
		
		BuildingEntry{
			BuildingType = "BUILDING_ROYAL_LIBRARY",
			BuildingSortColumn = "RoyalLibrarySort",
			IconControlNames = {"RoyalLibraryGreatWork"},
			HighlightIconControlNames = {"RoyalLibraryGreatWorkHL"},
			GhostIconControlNames = {"RoyalLibraryGreatWorkGhost"},
			ColumnImageControl = Controls.RoyalLibraryImage,
		},	
	};
	
	local WorldWonders = {};
	for building in GameInfo.Buildings() do
		local buildingClass = GameInfo.BuildingClasses[building.BuildingClass];
		if((buildingClass.MaxGlobalInstances > 0 and building.GreatWorkCount > 0) or
			building.Type == "BUILDING_HERMITAGE" or building.Type == "BUILDING_OXFORD_UNIVERSITY") then
			table.insert(WorldWonders, {
				BuildingID = building.ID,
				BuildingClassID = buildingClass.ID,
				GreatWorkSlotCount = building.GreatWorkCount,
				PortraitIndex = building.PortraitIndex,
				IconAtlas = building.IconAtlas,
				Description = building.Description,
				GreatWorkSlotType = building.GreatWorkSlotType,
				GreatWorkSlotIcons = greatWorkSlotIcons[building.GreatWorkSlotType],
			});
		end
	end


New Code (from line 562 too):
Spoiler :

Code:
    local buildings = {
		BuildingEntry{
			BuildingType = "BUILDING_AMPHITHEATER",
			BuildingSortColumn = "AmphitheaterSort",
			IconControlNames = {"AmphitheaterGreatWork"},
			HighlightIconControlNames = {"AmphitheaterGreatWorkHL"},
			GhostIconControlNames = {"AmphitheaterGreatWorkGhost"},
			ColumnImageControl = Controls.AmphitheaterImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_OPERA_HOUSE",
			BuildingSortColumn = "OperaHouseSort",
			IconControlNames = {"OperaHouseGreatWork"},
			HighlightIconControlNames = {"OperaHouseGreatWorkHL"},
			GhostIconControlNames = {"OperaHouseGreatWorkGhost"},
			ColumnImageControl = Controls.OperaHouseImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_MUSEUM",
			BuildingSortColumn = "MuseumSort",
			IconControlNames = {"MuseumGreatWork1", "MuseumGreatWork2"},
			HighlightIconControlNames = {"MuseumGreatWork1HL", "MuseumGreatWork2HL"},
			GhostIconControlNames = {"MuseumGreatWork1Ghost", "MuseumGreatWork2Ghost"},
			ThemeBonusControlName = "MuseumThemeBonus";
			ColumnImageControl = Controls.MuseumImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_BROADCAST_TOWER",
			BuildingSortColumn = "BroadcastTowerSort",
			IconControlNames = {"BroadcastTowerGreatWork"},
			HighlightIconControlNames = {"BroadcastTowerGreatWorkHL"},
			GhostIconControlNames = {"BroadcastTowerGreatWorkGhost"},
			ColumnImageControl = Controls.BroadcastTowerImage,
		},	
		BuildingEntry{
			BuildingType = "BUILDING_CATHEDRAL",
			BuildingSortColumn = "CathedralSort",
			IconControlNames = {"CathedralGreatWork"},
			HighlightIconControlNames = {"CathedralGreatWorkHL"},
			GhostIconControlNames = {"CathedralGreatWorkGhost"},
			ColumnImageControl = Controls.CathedralImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_PALACE",
			BuildingSortColumn = "PalaceSort",
			IconControlNames = {"PalaceGreatWork"},
			HighlightIconControlNames = {"PalaceGreatWorkHL"},
			GhostIconControlNames = {"PalaceGreatWorkGhost"},
			ColumnImageControl = Controls.PalaceImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_NATIONAL_EPIC",
			BuildingSortColumn = "NationalEpicSort",
			IconControlNames = {"NationalEpicGreatWork"},
			HighlightIconControlNames = {"NationalEpicGreatWorkHL"},
			GhostIconControlNames = {"NationalEpicGreatWorkGhost"},
			ColumnImageControl = Controls.NationalEpicImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_HEROIC_EPIC",
			BuildingSortColumn = "HeroicEpicSort",
			IconControlNames = {"HeroicEpicGreatWork"},
			HighlightIconControlNames = {"HeroicEpicGreatWorkHL"},
			GhostIconControlNames = {"HeroicEpicGreatWorkGhost"},
			ColumnImageControl = Controls.HeroicEpicImage,
		},		
		
		BuildingEntry{
			BuildingType = "BUILDING_ROYAL_LIBRARY",
			BuildingSortColumn = "RoyalLibrarySort",
			IconControlNames = {"RoyalLibraryGreatWork"},
			HighlightIconControlNames = {"RoyalLibraryGreatWorkHL"},
			GhostIconControlNames = {"RoyalLibraryGreatWorkGhost"},
			ColumnImageControl = Controls.RoyalLibraryImage,
		},	
	};
	
	local WorldWonders = {};
	for building in GameInfo.Buildings() do
		local buildingClass = GameInfo.BuildingClasses[building.BuildingClass];
		if(building.Type ~= "BUILDING_MUSEUM" and building.Type ~= "BUILDING_PALACE" and building.Type ~= "BUILDING_AMPHITHEATER" and building.Type ~= "BUILDING_OPERA_HOUSE" and building.Type ~= "BUILDING_BROADCAST_TOWER" and building.Type ~= "BUILDING_NATIONAL_EPIC" and building.Type ~= "BUILDING_HEROIC_EPIC" and building.Type ~= "BUILDING_ROYAL_LIBRARY" and building.Type ~= "BUILDING_CATHEDRAL" and building.GreatWorkCount > 0) then
			table.insert(WorldWonders, {
				BuildingID = building.ID,
				BuildingClassID = buildingClass.ID,
				GreatWorkSlotCount = building.GreatWorkCount,
				PortraitIndex = building.PortraitIndex,
				IconAtlas = building.IconAtlas,
				Description = building.Description,
				GreatWorkSlotType = building.GreatWorkSlotType,
				GreatWorkSlotIcons = greatWorkSlotIcons[building.GreatWorkSlotType],
			});
		end
	end


Also, if anyone finds a way of managing this without changing the DLL, well, it would be better. :goodjob:
 

Attachments

  • CultureOverview.rar
    12.7 KB · Views: 216
Note: If you are making an UB Override of a Building that already had GW slots, this isn't necessary, unless you also plan on changing the ammount of GW slots. The vertical columns have a hardcoded ammount of GW slots, so you'll need this Lua file anyway.

Summarizing:
  • If you need a UB that replaces another with GW slots, and will not change the number of slots, you don't need to do anything special.
  • if you make a Wonder with GW slots, you don't need it either.
  • Whatever other case with GW, replace CultureOverview.lua with the file linked above, with the same name and VFS=True on your mod.
 
So if I wanted to code some new buildings:
-Gallery: Unlocked at Chivalry: 1 culture, one slot for art. 1 gold maintenance.
-Church: Unlocked at Philosophy: 2 faith, great slot of music (this means the musicians guild is moved to philosophy)No Maintenance.

-Pub: Unlocked at Calender: +2 happiness, 2 gold in maintenance
-City Office: Unlocked at Science Theory (May change), gives 1 gold, one 2 science.
-City with snow in its workable tiles can build Ski Resort after building Hotel giving +1 Tourism
City on coast with coastal plains tile with town can build Beach Resort after building Hotel giving +1 Tourism
I need this?
Also I've never coded wonders, can one code a National wonder?
 
So if I wanted to code some new buildings:
-Gallery: Unlocked at Chivalry: 1 culture, one slot for art. 1 gold maintenance.
-Church: Unlocked at Philosophy: 2 faith, great slot of music (this means the musicians guild is moved to philosophy)No Maintenance.
Yeah, you'll need this
-Pub: Unlocked at Calender: +2 happiness, 2 gold in maintenance
-City Office: Unlocked at Science Theory (May change), gives 1 gold, one 2 science.
-City with snow in its workable tiles can build Ski Resort after building Hotel giving +1 Tourism
City on coast with coastal plains tile with town can build Beach Resort after building Hotel giving +1 Tourism
Won't need it for these though
Also I've never coded wonders, can one code a National wonder?
Absolutely. Check the building XML files on how to get a national wonder set up as such (Primarily the Buildings.xml and BuildingClasses.xml files) and one of my wonders as an example of how to set it up. I'm sure there are some national wonder mods available on Steam Workshop though, might pay to check out one of those.
 
Yeah, you'll need this

Won't need it for these though

Absolutely. Check the building XML files on how to get a national wonder set up as such (Primarily the Buildings.xml and BuildingClasses.xml files) and one of my wonders as an example of how to set it up. I'm sure there are some national wonder mods available on Steam Workshop though, might pay to check out one of those.

Thank you for the quick response!
 
So since I need is it's as simple as download then drop in enable VFS and that's it?
 
Thank you, will try to add my wonders and buildings to this lua part.
Is there any limit i should note?
 
I haven't tried it personally yet (Will be doing so soon), but as best as I can tell the only limit is practicality - if you have too many buildings / wonders the city panel is going to be massive, which will make it problematic to navigate the screen.
 
I haven't tried it personally yet (Will be doing so soon), but as best as I can tell the only limit is practicality - if you have too many buildings / wonders the city panel is going to be massive, which will make it problematic to navigate the screen.

Oh so you have to add your custom buildings to the lua? would it be like this if I wanted to put in a Gallery? Little confused here on how to use it and what to do with it. I don't use lua often.
Code:
local buildings = {
		BuildingEntry{
			BuildingType = "BUILDING_AMPHITHEATER",
			BuildingSortColumn = "AmphitheaterSort",
			IconControlNames = {"AmphitheaterGreatWork"},
			HighlightIconControlNames = {"AmphitheaterGreatWorkHL"},
			GhostIconControlNames = {"AmphitheaterGreatWorkGhost"},
			ColumnImageControl = Controls.AmphitheaterImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_OPERA_HOUSE",
			BuildingSortColumn = "OperaHouseSort",
			IconControlNames = {"OperaHouseGreatWork"},
			HighlightIconControlNames = {"OperaHouseGreatWorkHL"},
			GhostIconControlNames = {"OperaHouseGreatWorkGhost"},
			ColumnImageControl = Controls.OperaHouseImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_MUSEUM",
			BuildingSortColumn = "MuseumSort",
			IconControlNames = {"MuseumGreatWork1", "MuseumGreatWork2"},
			HighlightIconControlNames = {"MuseumGreatWork1HL", "MuseumGreatWork2HL"},
			GhostIconControlNames = {"MuseumGreatWork1Ghost", "MuseumGreatWork2Ghost"},
			ThemeBonusControlName = "MuseumThemeBonus";
			ColumnImageControl = Controls.MuseumImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_BROADCAST_TOWER",
			BuildingSortColumn = "BroadcastTowerSort",
			IconControlNames = {"BroadcastTowerGreatWork"},
			HighlightIconControlNames = {"BroadcastTowerGreatWorkHL"},
			GhostIconControlNames = {"BroadcastTowerGreatWorkGhost"},
			ColumnImageControl = Controls.BroadcastTowerImage,
		},	
		BuildingEntry{
			BuildingType = "BUILDING_CATHEDRAL",
			BuildingSortColumn = "CathedralSort",
			IconControlNames = {"CathedralGreatWork"},
			HighlightIconControlNames = {"CathedralGreatWorkHL"},
			GhostIconControlNames = {"CathedralGreatWorkGhost"},
			ColumnImageControl = Controls.CathedralImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_PALACE",
			BuildingSortColumn = "PalaceSort",
			IconControlNames = {"PalaceGreatWork"},
			HighlightIconControlNames = {"PalaceGreatWorkHL"},
			GhostIconControlNames = {"PalaceGreatWorkGhost"},
			ColumnImageControl = Controls.PalaceImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_NATIONAL_EPIC",
			BuildingSortColumn = "NationalEpicSort",
			IconControlNames = {"NationalEpicGreatWork"},
			HighlightIconControlNames = {"NationalEpicGreatWorkHL"},
			GhostIconControlNames = {"NationalEpicGreatWorkGhost"},
			ColumnImageControl = Controls.NationalEpicImage,
		},		
		BuildingEntry{
			BuildingType = "BUILDING_HEROIC_EPIC",
			BuildingSortColumn = "HeroicEpicSort",
			IconControlNames = {"HeroicEpicGreatWork"},
			HighlightIconControlNames = {"HeroicEpicGreatWorkHL"},
			GhostIconControlNames = {"HeroicEpicGreatWorkGhost"},
			ColumnImageControl = Controls.HeroicEpicImage,
		},		
		
		BuildingEntry{
			BuildingType = "BUILDING_ROYAL_LIBRARY",
			BuildingSortColumn = "RoyalLibrarySort",
			IconControlNames = {"RoyalLibraryGreatWork"},
			HighlightIconControlNames = {"RoyalLibraryGreatWorkHL"},
			GhostIconControlNames = {"RoyalLibraryGreatWorkGhost"},
			ColumnImageControl = Controls.RoyalLibraryImage,
		},
	
                BuildingEntry{
			BuildingType = "BUILDING_GALLERY",
			BuildingSortColumn = "GallerySort",
			IconControlNames = {"GalleryGreatWork"},
			HighlightIconControlNames = {"GalleryGreatWorkHL"},
			GhostIconControlNames = {"GalleryGreatWorkGhost"},
			ColumnImageControl = Controls.GalleryImage,
		},	
	};
	
	local WorldWonders = {};
	for building in GameInfo.Buildings() do
		local buildingClass = GameInfo.BuildingClasses[building.BuildingClass];
		if(building.Type ~= "BUILDING_MUSEUM" and building.Type ~= "BUILDING_PALACE" and building.Type ~= "BUILDING_AMPHITHEATER" and building.Type ~= "BUILDING_OPERA_HOUSE" and building.Type ~= "BUILDING_BROADCAST_TOWER" and building.Type ~= "BUILDING_NATIONAL_EPIC" and building.Type ~= "BUILDING_HEROIC_EPIC" and building.Type ~= "BUILDING_ROYAL_LIBRARY" and building.Type ~= "BUILDING_CATHEDRAL" and building.Type~="BUILDING_GALLERY" and building.GreatWorkCount > 0) then
			table.insert(WorldWonders, {
				BuildingID = building.ID,
				BuildingClassID = buildingClass.ID,
				GreatWorkSlotCount = building.GreatWorkCount,
				PortraitIndex = building.PortraitIndex,
				IconAtlas = building.IconAtlas,
				Description = building.Description,
				GreatWorkSlotType = building.GreatWorkSlotType,
				GreatWorkSlotIcons = greatWorkSlotIcons[building.GreatWorkSlotType],
			});
		end
	end
 
I'm pretty sure (Leugi would need to verify this) that what this Lua does is add the new building in where wonders go at the moment. I *think* you'd be able to modify the Lua to get it to show up as a column, but that causes compatibility issues with other Great Work mods that will be using this file, since they won't have the same version and they'll all be trying to overwrite each other's versions.
 
I'm just trying to figure out if its something I have to modifiy or leave alone and just throw it in.
 
Strange bug when adding new building to lua, cant open culture overview in game, but top panel is working. Maybe this is related to france iam playing.
 
I'm pretty sure (Leugi would need to verify this) that what this Lua does is add the new building in where wonders go at the moment. I *think* you'd be able to modify the Lua to get it to show up as a column, but that causes compatibility issues with other Great Work mods that will be using this file, since they won't have the same version and they'll all be trying to overwrite each other's versions.

This... Adding the buildings directly in the lua file so they show up there is not something I have attempted yet, but I believe there are some issues with that as there's more than one part to change... And also, it would generate compatibility issues for mods that also add things on the lua.

The lua file is mostly to allow other buildings to show up, regardless they are not mentioned in the lua. So, if I make a new building with 2 slots, it will automatically show up in the left rows without touching the lua file I uploaded.

___

However, if you plan on having the new building on the top, like the Museum or the Broadcast Tower, you must edit it more. At line 53 those columns start being defined, and you also need to add variables at line 563. I don't think this is advisable though, for it will cause compatibility issues with whatever other mod that does the same.
 
Moderator Action: Thread moved in Tutorials & Reference

Because that's something we may have to refer to often...
 
This... Adding the buildings directly in the lua file so they show up there is not something I have attempted yet, but I believe there are some issues with that as there's more than one part to change... And also, it would generate compatibility issues for mods that also add things on the lua.

The lua file is mostly to allow other buildings to show up, regardless they are not mentioned in the lua. So, if I make a new building with 2 slots, it will automatically show up in the left rows without touching the lua file I uploaded.

___

However, if you plan on having the new building on the top, like the Museum or the Broadcast Tower, you must edit it more. At line 53 those columns start being defined, and you also need to add variables at line 563. I don't think this is advisable though, for it will cause compatibility issues with whatever other mod that does the same.

No need for me to edit the file than while it would be nice for my buildings to be in columns I try my best to keep compatibility, that said my custom buildings showing up in the rows works fine if you ask, thanks for the file!
 
I'd not seen this thread and had come up with a different solution using XML, which you can see here.

Interesting!...

So, I'd say we now have two options. Through XML it requires a lot of hops and moves and workarounds, but is far more compatible... Through DLL its not so compatible but its more direct, use whichever suits your needs best :goodjob:
 
Top Bottom